diff options
-rw-r--r-- | backend.h | 8 | ||||
-rw-r--r-- | cache.c | 2 | ||||
-rw-r--r-- | cache.h | 2 | ||||
-rw-r--r-- | fs.c | 10 | ||||
-rw-r--r-- | fs.h | 2 | ||||
-rw-r--r-- | netfs.c | 24 | ||||
-rw-r--r-- | tarfs.c | 11 |
7 files changed, 31 insertions, 28 deletions
@@ -61,7 +61,7 @@ struct fs_backend error_t (*get_args)(char **argz, unsigned *argz_len); /* Set options (see netfs_set_options()). */ - error_t (*set_options)(char *argz, size_t argz_len); + error_t (*set_options)(const char *argz, size_t argz_len); /* @@ -87,21 +87,21 @@ struct fs_backend /* Changing a node */ error_t (* write_node) (struct node *np, off_t offset, - size_t *len, void* data); + size_t *len, const void* data); /* Change NP's stats. */ error_t (* change_stat)(struct node *np, const io_statbuf_t *new_stat); /* Creates a node named NAME in DIR which is locked. */ error_t (* create_node) (struct node **new, struct node *dir, - char *name, mode_t m); + const char *name, mode_t m); /* Unlinks NODE. NODE can be a directory in which case it is empty. */ error_t (* unlink_node) (struct node *node); /* Tries to create a hard link named NAME in DIR to file NODE. */ error_t (* link_node) (struct node *dir, struct node *target, - char *name, int excl); /* Same as netfs semantics */ + const char *name, int excl); /* Same as netfs semantics */ /* Makes NODE a symlink to TARGET. */ error_t (* symlink_node) (struct node *node, const char *target); @@ -367,7 +367,7 @@ cache_set_size (struct node *node, size_t size) /* Writes at most LEN bytes from NODE at OFFSET into BUF. Returns the amount of data actually written in AMOUNT. */ error_t -cache_write (struct node *node, off_t offset, void *data, +cache_write (struct node *node, off_t offset, const void *data, size_t len, size_t *amount) { error_t err = 0; @@ -69,7 +69,7 @@ extern error_t cache_read (struct node *node, off_t offset, /* Writes at most LEN bytes from NODE at OFFSET into BUF. Returns the amount of data actually written in AMOUNT. */ extern error_t cache_write (struct node *node, off_t offset, - void *data, size_t len, size_t *amount); + const void *data, size_t len, size_t *amount); /* Sets the size of NODE and reduce/grow its cache. */ extern error_t cache_set_size (struct node *node, size_t size); @@ -135,7 +135,7 @@ filter_node_name (char* name) /* Returns either NULL or a pointer to a node if found. */ static inline struct node* -_find_node (struct node *dir, char *name) +_find_node (struct node *dir, const char *name) { struct node *node = NULL; @@ -176,7 +176,7 @@ _find_node (struct node *dir, char *name) } struct node * -fs_find_node (struct node *dir, char *name) +fs_find_node (struct node *dir, const char *name) { return _find_node (dir, name); } @@ -461,9 +461,10 @@ fs_get_path_from_root (struct node *root, struct node *node) if (strlen (path) + strlen (n->nn->name) + 1 + 1 > len) { char* new; + size_t offset = ptr - path; len *= 2; new = realloc (path, len); - ptr = new + (ptr - path); + ptr = new + offset; path = new; } REVERSE_COPY (ptr, n->nn->name); @@ -507,9 +508,10 @@ fs_get_path_to_root (struct node *root, struct node *node) if (strlen (path) + 3 + 1 > len) { char* new; + size_t offset = ptr - path; len *= 2; new = realloc (path, len); - ptr = new + (ptr - path); + ptr = new + offset; path = new; } strncpy (ptr, "../", 3); @@ -48,7 +48,7 @@ extern error_t fs_dir_last_entry (struct node *dir, struct node **last); /* Returns either NULL or a pointer to a node if found. */ extern struct node* -fs_find_node (struct node *dir, char *name); +fs_find_node (struct node *dir, const char *name); /* Looks for a node located at PATH, starting at directory N. When looking for "/foo/bar": @@ -48,7 +48,7 @@ extern struct fs_backend backend; This call should unlock DIR no matter what.) */ error_t netfs_attempt_lookup (struct iouser *user, struct node *dir, - char *name, struct node **np) + const char *name, struct node **np) { error_t err = 0; @@ -142,7 +142,7 @@ netfs_attempt_read (struct iouser *cred, struct node *np, return. */ error_t netfs_attempt_write (struct iouser *cred, struct node *np, - loff_t offset, size_t *len, void *data) + loff_t offset, size_t *len, const void *data) { if (! backend.write_node) return EROFS; @@ -440,7 +440,7 @@ netfs_attempt_syncfs (struct iouser *cred, int wait) CRED. NP is locked. */ error_t netfs_set_translator (struct iouser *cred, struct node *np, - char *argz, size_t argzlen) + const char *argz, size_t argzlen) { return EOPNOTSUPP; } @@ -574,7 +574,7 @@ netfs_attempt_chmod (struct iouser *cred, struct node *np, (user CRED) into a symlink with target NAME. */ error_t netfs_attempt_mksymlink (struct iouser *cred, struct node *np, - char *name) + const char *name) { error_t err; @@ -629,7 +629,7 @@ netfs_attempt_chflags (struct iouser *cred, struct node *np, locked) for USER. */ error_t netfs_attempt_unlink (struct iouser *user, struct node *dir, - char *name) + const char *name) { error_t err; @@ -666,8 +666,8 @@ netfs_attempt_unlink (struct iouser *user, struct node *dir, are locked. */ error_t netfs_attempt_rename (struct iouser *user, struct node *fromdir, - char *fromname, struct node *todir, - char *toname, int excl) + const char *fromname, struct node *todir, + const char *toname, int excl) { debug (("FIXME: Not implemented")); return EOPNOTSUPP; @@ -678,7 +678,7 @@ netfs_attempt_rename (struct iouser *user, struct node *fromdir, MODE. */ error_t netfs_attempt_mkdir (struct iouser *user, struct node *dir, - char *name, mode_t mode) + const char *name, mode_t mode) { error_t err = fshelp_isowner (&dir->nn_stat, user); struct node *newdir; @@ -695,7 +695,7 @@ netfs_attempt_mkdir (struct iouser *user, struct node *dir, /* The user must define this function. Attempt to remove directory named NAME in DIR (which is locked) for USER. */ error_t -netfs_attempt_rmdir (struct iouser *user, struct node *dir, char *name) +netfs_attempt_rmdir (struct iouser *user, struct node *dir, const char *name) { /* Simply redirect the call */ return netfs_attempt_unlink (user, dir, name); @@ -708,7 +708,7 @@ netfs_attempt_rmdir (struct iouser *user, struct node *dir, char *name) NAME is already found in DIR. */ error_t netfs_attempt_link (struct iouser *user, struct node *dir, - struct node *file, char *name, int excl) + struct node *file, const char *name, int excl) { error_t err; @@ -743,7 +743,7 @@ netfs_attempt_mkfile (struct iouser *user, struct node *dir, locked on success; no matter what, unlock DIR before returning. */ error_t netfs_attempt_create_file (struct iouser *user, struct node *dir, - char *name, mode_t mode, struct node **np) + const char *name, mode_t mode, struct node **np) { error_t err = fshelp_isowner (&dir->nn_stat, user); @@ -792,7 +792,7 @@ netfs_append_args (char **argz, unsigned *argz_len) returned if some option is unrecognized. The default definition of this routine will parse them using NETFS_RUNTIME_ARGP. */ error_t -netfs_set_options (char *argz, size_t argz_len) +netfs_set_options (const char *argz, size_t argz_len) { error_t err = EINVAL; @@ -255,6 +255,7 @@ tarfs_get_args (char **argz, unsigned *argz_len) break; case COMPRESS_BZIP2: err = argz_add (argz, argz_len, "--bzip2"); + break; } if (err) @@ -269,7 +270,7 @@ tarfs_get_args (char **argz, unsigned *argz_len) fsysopts): for instance, --no-timeout won't work (it doesn't make sense when tarfs is already running). */ error_t -tarfs_set_options (char *argz, size_t argz_len) +tarfs_set_options (const char *argz, size_t argz_len) { error_t err = 0; @@ -319,7 +320,7 @@ tarfs_set_options (char *argz, size_t argz_len) error_t tarfs_create_node (struct node **newnode, struct node *dir, - char *name, mode_t mode); + const char *name, mode_t mode); /* This function is called every time a header has been successfully parsed. It simply creates the node corresponding to the header. @@ -768,7 +769,7 @@ tarfs_read_node (struct node *node, off_t offset, size_t *len, void* data) /* Write to NODE through its cache. */ error_t -tarfs_write_node (struct node *node, off_t offset, size_t *len, void *data) +tarfs_write_node (struct node *node, off_t offset, size_t *len, const void *data) { IF_RWFS; @@ -828,7 +829,7 @@ tarfs_change_stat (struct node *node, const io_statbuf_t *st) it will point to the new node. NAME is duplicated. */ error_t tarfs_create_node (struct node **newnode, struct node *dir, - char *name, mode_t mode) + const char *name, mode_t mode) { error_t err; struct node *new = NULL; @@ -931,7 +932,7 @@ tarfs_free_node (struct node *node) /* Tries to create a hard link named NAME in DIR to file NODE. */ error_t tarfs_link_node (struct node *dir, struct node *target, - char *name, int excl) + const char *name, int excl) { error_t err = 0; struct tar_item *prev_tar, *tar; |