diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 7 | ||||
-rw-r--r-- | include/fstree.h | 18 |
2 files changed, 19 insertions, 6 deletions
diff --git a/include/common.h b/include/common.h index 84ec3ca..30c30fe 100644 --- a/include/common.h +++ b/include/common.h @@ -69,4 +69,11 @@ ostream_t *data_writer_ostream_create(const char *filename, sqfs_inode_generic_t **inode, int flags); +/* + Parse a comma separated list (e.g. "uid=...,gid=..." of defaults for + fstree nodes. Used for command line parsing. Returns 0 on success, + -1 on failure. Prints an error message to stderr on failure. + */ +int parse_fstree_defaults(fstree_defaults_t *out, char *str); + #endif /* COMMON_H */ diff --git a/include/fstree.h b/include/fstree.h index 51e2fbc..653e180 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -37,6 +37,7 @@ enum { #define FSTREE_MODE_HARD_LINK (0) #define FSTREE_MODE_HARD_LINK_RESOLVED (1) +typedef struct fstree_defaults_t fstree_defaults_t; typedef struct tree_node_t tree_node_t; typedef struct file_info_t file_info_t; typedef struct dir_info_t dir_info_t; @@ -120,9 +121,18 @@ struct tree_node_t { sqfs_u8 payload[]; }; +/* Default settings for new nodes */ +struct fstree_defaults_t { + sqfs_u32 uid; + sqfs_u32 gid; + sqfs_u32 mtime; + sqfs_u16 mode; +}; + /* Encapsulates a file system tree */ struct fstree_t { - struct stat defaults; + fstree_defaults_t defaults; + size_t unique_inode_count; /* flat array of all nodes that have an inode number */ @@ -138,13 +148,9 @@ struct fstree_t { Initializing means copying over the default values and creating a root node. On error, an error message is written to stderr. - The string `defaults` can specify default attributes (mode, uid, gid, mtime) - as a comma separated list of key value paris (<key>=<value>[,...]). The string - is passed to getsubopt and will be altered. - Returns 0 on success. */ -int fstree_init(fstree_t *fs, char *defaults); +int fstree_init(fstree_t *fs, const fstree_defaults_t *defaults); void fstree_cleanup(fstree_t *fs); |