From be645920ae72ae7d407e8d976506f617a7d40355 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 13 Feb 2015 15:20:09 +0100 Subject: Unlink function now called delete() (becaue that's what it does) --- src/kernel/include/vfs.h | 8 ++++---- src/kernel/user/nullfs.c | 14 +++++++------- src/kernel/user/vfs.c | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/kernel/include/vfs.h b/src/kernel/include/vfs.h index 140365c..19f43db 100644 --- a/src/kernel/include/vfs.h +++ b/src/kernel/include/vfs.h @@ -56,8 +56,8 @@ typedef struct fs_handle { // - nodes keep a reference to their parent // - a FS node is either in memory (after one call to walk() on its parent), or not in memory // it can be in memory only once : if it is in memory, walk() cannot be called on the parent again -// - unlink() is expected to unlink the node from its parent (make it inaccessible) and delete -// the corresponding data. It is guaranteed that unlink() is never called on a node that +// - delete() is expected to unlink the node from its parent (make it inaccessible) and delete +// the corresponding data. It is guaranteed that delete() is never called on a node that // is currently in use. (different from posix semantics !) // - the root node of a filesystem is created when the filesystem is created // - dispose() is not called on the root node when a filesystem is shutdown @@ -66,7 +66,7 @@ typedef struct { bool (*open)(fs_node_ptr n, int mode, fs_handle_t *s); // open current node bool (*stat)(fs_node_ptr n, stat_t *st); bool (*walk)(fs_node_ptr n, const char* file, struct fs_node *node_d); - bool (*unlink)(fs_node_ptr n, const char* file); + bool (*delete)(fs_node_ptr n, const char* file); bool (*move)(fs_node_ptr dir, const char* old_name, struct fs_node *new_parent, const char *new_name); bool (*create)(fs_node_ptr n, const char* name, int type); // create sub-node in directory int (*ioctl)(fs_node_ptr n, int command, void* data); @@ -138,7 +138,7 @@ void ref_fs(fs_t *fs); void unref_fs(fs_t *fs); bool fs_create(fs_t *fs, const char* file, int type); -bool fs_unlink(fs_t *fs, const char* file); +bool fs_delete(fs_t *fs, const char* file); bool fs_move(fs_t *fs, const char* from, const char* to); bool fs_stat(fs_t *fs, const char* file, stat_t *st); int fs_ioctl(fs_t *fs, const char* file, int command, void* data); diff --git a/src/kernel/user/nullfs.c b/src/kernel/user/nullfs.c index ec80fb1..2f54137 100644 --- a/src/kernel/user/nullfs.c +++ b/src/kernel/user/nullfs.c @@ -15,7 +15,7 @@ static void nullfs_fs_shutdown(fs_ptr fs); static bool nullfs_d_open(fs_node_ptr n, int mode, fs_handle_t *s); static bool nullfs_d_stat(fs_node_ptr n, stat_t *st); static bool nullfs_d_walk(fs_node_ptr n, const char* file, struct fs_node *node_d); -static bool nullfs_d_unlink(fs_node_ptr n, const char* file); +static bool nullfs_d_delete(fs_node_ptr n, const char* file); static bool nullfs_d_move(fs_node_ptr n, const char* old_name, fs_node_t *new_parent, const char *new_name); static bool nullfs_d_create(fs_node_ptr n, const char* file, int type); static void nullfs_d_dispose(fs_node_ptr n); @@ -49,7 +49,7 @@ static fs_node_ops_t nullfs_d_ops = { .open = nullfs_d_open, .stat = nullfs_d_stat, .walk = nullfs_d_walk, - .unlink = nullfs_d_unlink, + .delete = nullfs_d_delete, .move = nullfs_d_move, .create = nullfs_d_create, .dispose = nullfs_d_dispose, @@ -69,7 +69,7 @@ static fs_node_ops_t nullfs_f_ops = { .dispose = nullfs_f_dispose, .walk = 0, .create = 0, - .unlink = 0, + .delete = 0, .move = 0, .ioctl =0, }; @@ -87,7 +87,7 @@ static fs_handle_ops_t nullfs_fh_ops = { // ====================== // typedef struct { - bool can_create, can_move, can_unlink; + bool can_create, can_move, can_delete; } nullfs_t; typedef struct nullfs_item { @@ -138,7 +138,7 @@ bool nullfs_fs_make(fs_handle_t *source, char* opts, fs_t *fs_s) { fs->can_create = (strchr(opts, 'c') != 0); fs->can_move = (strchr(opts, 'm') != 0); - fs->can_unlink = (strchr(opts, 'd') != 0); + fs->can_delete = (strchr(opts, 'd') != 0); nullfs_dir_t *root = (nullfs_dir_t*)malloc(sizeof(nullfs_dir_t)); if (root == 0) { @@ -264,7 +264,7 @@ bool nullfs_d_stat(fs_node_ptr n, stat_t *st) { st->access = FM_READDIR | (d->fs->can_create ? FM_DCREATE : 0) | (d->fs->can_move ? FM_DMOVE : 0) - | (d->fs->can_unlink ? FM_DUNLINK : 0); + | (d->fs->can_delete ? FM_DUNLINK : 0); st->size = 0; for (nullfs_item_t *i = d->items_list; i != 0; i = i->next) @@ -294,7 +294,7 @@ bool nullfs_d_walk(fs_node_ptr n, const char* file, struct fs_node *node_d) { return true; } -bool nullfs_d_unlink(fs_node_ptr n, const char* file) { +bool nullfs_d_delete(fs_node_ptr n, const char* file) { return false; //TODO } diff --git a/src/kernel/user/vfs.c b/src/kernel/user/vfs.c index 995bfbc..5ba2064 100644 --- a/src/kernel/user/vfs.c +++ b/src/kernel/user/vfs.c @@ -245,7 +245,7 @@ bool fs_create(fs_t *fs, const char* file, int type) { return ret; } -bool fs_unlink(fs_t *fs, const char* file) { +bool fs_delete(fs_t *fs, const char* file) { char name[DIR_MAX]; fs_node_t* n = fs_walk_path_except_last(&fs->root, file, name); @@ -256,7 +256,7 @@ bool fs_unlink(fs_t *fs, const char* file) { if (x != 0) return false; } - bool ret = n->ops->unlink && n->ops->unlink(n->data, name); + bool ret = n->ops->delete && n->ops->delete(n->data, name); unref_fs_node(n); return ret; } -- cgit v1.2.3