1.1 --- a/libe2access/host/e2access.c Thu Feb 17 19:42:31 2022 +0100
1.2 +++ b/libe2access/host/e2access.c Thu Feb 17 22:12:53 2022 +0100
1.3 @@ -230,7 +230,7 @@
1.4 {
1.5 /* Only a non-existent file in an existing directory is permitted. */
1.6
1.7 - if (!_image_isdir(fs, ino_target) || !path_is_leafname(target_remaining))
1.8 + if (!image_isdir_by_inode(fs, ino_target) || !path_is_leafname(target_remaining))
1.9 {
1.10 fprintf(stderr, "Target not found: %s\n", target);
1.11 return 1;
1.12 @@ -241,7 +241,7 @@
1.13 }
1.14 else
1.15 {
1.16 - target_is_file = _image_isfile(fs, ino_target);
1.17 + target_is_file = image_isfile_by_inode(fs, ino_target);
1.18 target_is_new = 0;
1.19 }
1.20
1.21 @@ -255,7 +255,7 @@
1.22 return 1;
1.23 }
1.24 }
1.25 - else if (!_image_isdir(fs, ino_target))
1.26 + else if (!image_isdir_by_inode(fs, ino_target))
1.27 {
1.28 fprintf(stderr, "Target is not a directory: %s\n", target);
1.29 return 1;
1.30 @@ -397,7 +397,7 @@
1.31
1.32 for (i = 0; i < argc - 1; i++)
1.33 {
1.34 - if (!image_isfile(fs, argv[i]))
1.35 + if (!image_isfile_by_path(fs, argv[i]))
1.36 {
1.37 fprintf(stderr, "Source is not a file: %s\n", argv[i]);
1.38 return 1;
1.39 @@ -509,7 +509,7 @@
1.40
1.41 /* Detect missing objects. */
1.42
1.43 - if ((!*path) || !image_exists(fs, path))
1.44 + if ((!*path) || image_find_by_path(fs, path, &ino))
1.45 {
1.46 fprintf(stderr, "Not found: %s\n", path);
1.47 return 1;
1.48 @@ -519,7 +519,7 @@
1.49
1.50 if (dir_only)
1.51 {
1.52 - if (!image_isdir(fs, path))
1.53 + if (!image_isdir_by_inode(fs, ino))
1.54 {
1.55 fprintf(stderr, "Not a directory: %s\n", path);
1.56 return 1;
1.57 @@ -527,7 +527,7 @@
1.58
1.59 /* Test for an empty directory. */
1.60
1.61 - if (image_dir_empty_by_path(fs, path, &ino))
1.62 + if (image_dir_empty_by_inode(fs, ino))
1.63 {
1.64 fprintf(stderr, "Directory not empty: %s\n", path);
1.65 return 1;
1.66 @@ -536,7 +536,7 @@
1.67
1.68 /* Otherwise, insist on a non-directory. */
1.69
1.70 - else if (image_isdir_by_path(fs, path, &ino))
1.71 + else if (image_isdir_by_inode(fs, ino))
1.72 {
1.73 fprintf(stderr, "Cannot remove a directory: %s\n", path);
1.74 return 1;
2.1 --- a/libe2access/include/e2access/image.h Thu Feb 17 19:42:31 2022 +0100
2.2 +++ b/libe2access/include/e2access/image.h Thu Feb 17 22:12:53 2022 +0100
2.3 @@ -107,19 +107,15 @@
2.4
2.5 /* Presence and type tests. */
2.6
2.7 -int image_exists(ext2_filsys fs, const char *name);
2.8 +int image_exists(ext2_filsys fs, const char *path);
2.9
2.10 -int _image_isdir(ext2_filsys fs, ext2_ino_t ino);
2.11 -
2.12 -int image_isdir(ext2_filsys fs, const char *name);
2.13 +int image_isdir_by_inode(ext2_filsys fs, ext2_ino_t ino);
2.14
2.15 -int image_isdir_by_path(ext2_filsys fs, const char *name, ext2_ino_t *ino);
2.16 -
2.17 -int _image_isfile(ext2_filsys fs, ext2_ino_t ino);
2.18 +int image_isdir_by_path(ext2_filsys fs, const char *path);
2.19
2.20 -int image_isfile(ext2_filsys fs, const char *name);
2.21 +int image_isfile_by_inode(ext2_filsys fs, ext2_ino_t ino);
2.22
2.23 -int image_isfile_by_path(ext2_filsys fs, const char *name, ext2_ino_t *ino);
2.24 +int image_isfile_by_path(ext2_filsys fs, const char *path);
2.25
2.26 #ifdef __cplusplus
2.27 }
3.1 --- a/libe2access/lib/src/image.c Thu Feb 17 19:42:31 2022 +0100
3.2 +++ b/libe2access/lib/src/image.c Thu Feb 17 22:12:53 2022 +0100
3.3 @@ -378,7 +378,7 @@
3.4 return retval;
3.5 }
3.6
3.7 - if (!_image_isdir(fs, ino))
3.8 + if (!image_isdir_by_inode(fs, ino))
3.9 return 1;
3.10
3.11 /* List the directory contents. */
3.12 @@ -487,7 +487,7 @@
3.13 struct ext2_inode_large inode;
3.14 ext2_ino_t ino_parent = 0;
3.15 errcode_t retval;
3.16 - int isdir = _image_isdir(fs, ino);
3.17 + int isdir = image_isdir_by_inode(fs, ino);
3.18
3.19 if (isdir)
3.20 {
3.21 @@ -585,7 +585,7 @@
3.22 if (retval)
3.23 return retval;
3.24
3.25 - if (_image_isdir(fs, source))
3.26 + if (image_isdir_by_inode(fs, source))
3.27 {
3.28 /* Update the link count for the target. */
3.29
3.30 @@ -713,14 +713,14 @@
3.31
3.32 /* Test object presence and types in the filesystem image. */
3.33
3.34 -int image_exists(ext2_filsys fs, const char *name)
3.35 +int image_exists(ext2_filsys fs, const char *path)
3.36 {
3.37 ext2_ino_t ino;
3.38
3.39 - return !image_find_by_path(fs, name, &ino);
3.40 + return !image_find_by_path(fs, path, &ino);
3.41 }
3.42
3.43 -int _image_isdir(ext2_filsys fs, ext2_ino_t ino)
3.44 +int image_isdir_by_inode(ext2_filsys fs, ext2_ino_t ino)
3.45 {
3.46 struct ext2_inode inode;
3.47
3.48 @@ -730,22 +730,17 @@
3.49 return LINUX_S_ISDIR(inode.i_mode);
3.50 }
3.51
3.52 -int image_isdir(ext2_filsys fs, const char *name)
3.53 +int image_isdir_by_path(ext2_filsys fs, const char *path)
3.54 {
3.55 ext2_ino_t ino;
3.56
3.57 - return image_isdir_by_path(fs, name, &ino);
3.58 + if (image_find_by_path(fs, path, &ino))
3.59 + return 0;
3.60 +
3.61 + return image_isdir_by_inode(fs, ino);
3.62 }
3.63
3.64 -int image_isdir_by_path(ext2_filsys fs, const char *name, ext2_ino_t *ino)
3.65 -{
3.66 - if (image_find_by_path(fs, name, ino))
3.67 - return 0;
3.68 -
3.69 - return _image_isdir(fs, *ino);
3.70 -}
3.71 -
3.72 -int _image_isfile(ext2_filsys fs, ext2_ino_t ino)
3.73 +int image_isfile_by_inode(ext2_filsys fs, ext2_ino_t ino)
3.74 {
3.75 struct ext2_inode inode;
3.76
3.77 @@ -755,19 +750,14 @@
3.78 return LINUX_S_ISREG(inode.i_mode);
3.79 }
3.80
3.81 -int image_isfile(ext2_filsys fs, const char *name)
3.82 +int image_isfile_by_path(ext2_filsys fs, const char *path)
3.83 {
3.84 ext2_ino_t ino;
3.85
3.86 - return image_isfile_by_path(fs, name, &ino);
3.87 -}
3.88 -
3.89 -int image_isfile_by_path(ext2_filsys fs, const char *name, ext2_ino_t *ino)
3.90 -{
3.91 - if (image_find_by_path(fs, name, ino))
3.92 + if (image_find_by_path(fs, path, &ino))
3.93 return 0;
3.94
3.95 - return _image_isfile(fs, *ino);
3.96 + return image_isfile_by_inode(fs, ino);
3.97 }
3.98
3.99 /* vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/libe2access/lib/src/utils.c Thu Feb 17 19:42:31 2022 +0100
4.2 +++ b/libe2access/lib/src/utils.c Thu Feb 17 22:12:53 2022 +0100
4.3 @@ -39,7 +39,7 @@
4.4
4.5 /* Select a specific object, if appropriate. */
4.6
4.7 - if (!image_isdir(fs, path))
4.8 + if (!image_isdir_by_path(fs, path))
4.9 data.filename = path_basename(path);
4.10 else
4.11 data.filename = NULL;
4.12 @@ -76,7 +76,7 @@
4.13 owner, group and size information. */
4.14
4.15 printf("%s%s %5d %5d %6lld ",
4.16 - _image_isdir(fs, dirent->inode) ? "d" : "-",
4.17 + image_isdir_by_inode(fs, dirent->inode) ? "d" : "-",
4.18 get_permission_string(inode.i_mode),
4.19 inode.i_uid,
4.20 inode.i_gid,
5.1 --- a/libfsserver/lib/files/ext2_file_operations.cc Thu Feb 17 19:42:31 2022 +0100
5.2 +++ b/libfsserver/lib/files/ext2_file_operations.cc Thu Feb 17 22:12:53 2022 +0100
5.3 @@ -59,7 +59,7 @@
5.4 {
5.5 std::lock_guard<std::mutex> guard(_lock);
5.6
5.7 - return _image_isdir(_fs, ino_file);
5.8 + return image_isdir_by_inode(_fs, ino_file);
5.9 }
5.10
5.11 /* Test for a file. */
5.12 @@ -68,7 +68,7 @@
5.13 {
5.14 std::lock_guard<std::mutex> guard(_lock);
5.15
5.16 - return _image_isfile(_fs, ino_file);
5.17 + return image_isfile_by_inode(_fs, ino_file);
5.18 }
5.19
5.20
5.21 @@ -119,7 +119,7 @@
5.22 std::lock_guard<std::mutex> guard(_lock);
5.23
5.24 *remaining = path;
5.25 - errcode_t retval = image_find_path(_fs, remaining, ino);
5.26 + errcode_t retval = image_resolve_by_path(_fs, remaining, ino);
5.27
5.28 // NOTE: Map error conditions.
5.29