aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-02 17:22:24 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-02 17:22:24 +0200
commit9940efe053263478c5f29367b11d6f7ed1276aa4 (patch)
tree99d1c9e9712c73ba4e6e8e145f007cb74294f12a /include
parent32eb57dd9a19254565a0792ab9b627a3dac319f9 (diff)
Move fstree CLI code to libcommon
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r--include/common.h7
-rw-r--r--include/fstree.h18
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);