Changeset b017885 in mainline for uspace/app/cmpdirs/cmpdirs.c


Ignore:
Timestamp:
2026-03-17T12:37:41Z (24 hours ago)
Author:
Vít Skalický <skalicky@…>
Children:
74c69dc
Parents:
7952b336
git-author:
Vít Skalický <skalicky@…> (2026-03-17 12:16:27)
git-committer:
Vít Skalický <skalicky@…> (2026-03-17 12:37:41)
Message:

Fix use of vfs_walk()

Added slash to the beginning of file names in dirent so that they are
an absolute path. vfs_walk() resolves path staring from the directory
passed as parent, but the paths themselves must be absolute (start
with /).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/cmpdirs/cmpdirs.c

    r7952b336 rb017885  
    334334                                assert(rc != EOK);
    335335                        }
    336                         check_ok(rc, close_inner, "Failed to open directory (handle %d", item.handle1);
     336                        check_ok(rc, close_inner, "Failed to open directory of handle %d", item.handle1);
    337337
    338338                        while ((dp = readdir(dirp))) { // 1.
     
    345345                                }
    346346                                check_ok_break(rc, "Name too long (limit is %"PRIdn" excluding null-terminator)", name_buffer_size);
     347                                // add slash to the beginning of the name, because vfs_walk requires the path to be absolute (will be
     348                                // resolved relatively to the starting directory)
     349                                char name_with_slash[name_buffer_size+1];
     350                                name_with_slash[0] = '/';
     351                                str_cpy(name_with_slash + 1, name_size + 1, dp->d_name);
    347352                                // 2.
    348353                                int entry_handle1; // don't forget to put
    349                                 rc = vfs_walk(item.handle1, dp->d_name, 0, &entry_handle1);
    350                                 check_ok_break(rc, "(0) Failed to find entry \"%s\" in directory of handle %d\n", dp->d_name, item.handle1);
     354                                rc = vfs_walk(item.handle1, name_with_slash, 0, &entry_handle1);
     355                                check_ok_break(rc, "(0) Failed to find entry \"%s\" in directory of handle %d\n", name_with_slash, item.handle1);
    351356                                // 3.
    352357                                int entry_handle2; // must be put
    353                                 rc= vfs_walk(item.handle2, dp->d_name, 0, &entry_handle2);
     358                                rc= vfs_walk(item.handle2, name_with_slash, 0, &entry_handle2);
    354359                                if (rc != EOK) {
    355360                                        errno_t rc2 = vfs_put(entry_handle1);
     
    360365                                                break;
    361366                                        }
    362                                         check_ok_break(rc, "(1) Failed to find entry \"%s\" in directory of handle %d\n", dp->d_name, item.handle2);
     367                                        check_ok_break(rc, "(1) Failed to find entry \"%s\" in directory of handle %d\n", name_with_slash, item.handle2);
    363368                                }
    364369
Note: See TracChangeset for help on using the changeset viewer.