# HG changeset patch # User Paul Boddie # Date 1646343775 -3600 # Node ID e9156da534d0d652721df053060a922e36059be3 # Parent f488a98bcc342cabc8a6b0eca45da5c2c8227f22 Ensure image_resolve_by_path result initialisation. Tidied up docstrings. diff -r f488a98bcc34 -r e9156da534d0 libe2access/lib/src/image.c --- a/libe2access/lib/src/image.c Wed Mar 02 23:53:42 2022 +0100 +++ b/libe2access/lib/src/image.c Thu Mar 03 22:42:55 2022 +0100 @@ -225,14 +225,14 @@ } } -/* Find an object with the given path in the filesystem image. */ +/* Find an object with the given path. */ errcode_t image_find_by_path(ext2_filsys fs, const char *path, ext2_ino_t *ino) { return image_resolve_by_path(fs, &path, ino); } -/* Find an object with the given path in the filesystem image. */ +/* Find an object with the given path. */ errcode_t image_resolve_by_path(ext2_filsys fs, const char **path, ext2_ino_t *ino) @@ -241,7 +241,12 @@ ext2_ino_t ino_dir; errcode_t retval; + /* Initialise the inode in case of early failure. */ + + *ino = 0; + retval = ext2fs_get_mem(fs->blocksize, &buf); + if (retval) return retval; @@ -278,8 +283,8 @@ return retval; } -/* Find an object in the given directory with the given name in the filesystem - image, updating the name reference to refer to the next component. */ +/* Find an object in the given directory with the given name, updating the name + reference to refer to the next component. */ errcode_t image_resolve_next(ext2_filsys fs, ext2_ino_t ino_dir, const char **basename, char *buf, ext2_ino_t *ino) @@ -299,8 +304,7 @@ return retval; } -/* Find an object in the given directory with the given name in the filesystem - image. */ +/* Find an object in the given directory with the given name. */ errcode_t image_find_file(ext2_filsys fs, const char *dirname, const char *basename, ext2_ino_t *ino) @@ -314,8 +318,7 @@ return image_find_by_path(fs, path, ino); } -/* Obtain the inode for the object with the given path in the filesystem - image. */ +/* Obtain the inode for the object with the given path. */ errcode_t image_inode(ext2_filsys fs, const char *path, struct ext2_inode *inode) @@ -353,7 +356,7 @@ return ext2fs_write_inode(fs, ino, &inode); } -/* List a directory in the filesystem image. */ +/* List a directory. */ errcode_t image_list_dir(ext2_filsys fs, const char *path, int (*proc)(struct ext2_dir_entry *, int, int, char *, @@ -395,8 +398,8 @@ return 0; } -/* Make a directory in the given directory in the filesystem image having the - given name and metadata. */ +/* Make a directory in the given directory having the given name and + metadata. */ errcode_t image_make_dir(ext2_filsys fs, ext2_ino_t ino_dir, const char *basename, __u16 mode, @@ -426,8 +429,8 @@ return ext2fs_write_inode(fs, *ino, &inode_dir); } -/* Make a directory in the given directory in the filesystem image, updating - the name reference to refer to the next component. */ +/* Make a directory in the given directory, updating the name reference to refer + to the next component. */ errcode_t image_make_next_dir(ext2_filsys fs, ext2_ino_t ino_dir, const char **basename, __u16 mode, __u16 uid, @@ -458,7 +461,7 @@ return retval; } -/* Make directories descending to the given path in the filesystem image. */ +/* Make directories descending to the given path. */ errcode_t image_make_dirs(ext2_filsys fs, const char **path, ext2_ino_t ino_dir, __u16 mode, __u16 uid, __u16 gid) @@ -713,7 +716,7 @@ -/* Test object presence and types in the filesystem image. */ +/* Test object presence and types. */ int image_exists(ext2_filsys fs, const char *path) {