diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-04-24 18:51:54 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-04-24 18:51:54 -0400 |
commit | 4c30e215d9a5e18aa013fb2ffcac50ebc9eb6a7d (patch) | |
tree | e1f8e147713fbcb19c41249b1f8b27ce5f16f21b | |
parent | 81d8eb2fe4188878028fd4da07f4edf12c648168 (diff) | |
download | dbfs-4c30e215d9a5e18aa013fb2ffcac50ebc9eb6a7d.tar.gz |
dbfs: Shuffle code to match order in fuse_lowlevel_ops. No code changes.
-rw-r--r-- | dbfs.c | 132 |
1 files changed, 66 insertions, 66 deletions
@@ -13,6 +13,29 @@ #include <db.h> #include "dbfs.h" +static void dbfs_op_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) +{ + struct fuse_entry_param e; + guint64 ino; + int rc; + + /* lookup inode in parent directory */ + rc = dbfs_lookup(parent, name, &ino); + if (rc) { + fuse_reply_err(req, rc); + return; + } + + /* send reply; timeout of 2.0 is just a guess */ + + memset(&e, 0, sizeof(e)); + e.ino = ino; + e.attr_timeout = 2.0; + e.entry_timeout = 2.0; + + fuse_reply_entry(req, &e); +} + static void dbfs_op_getattr(fuse_req_t req, fuse_ino_t ino_n, struct fuse_file_info *fi) { @@ -72,27 +95,55 @@ static void dbfs_op_readlink(fuse_req_t req, fuse_ino_t ino) free(val.data); } -static void dbfs_op_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) +static void dbfs_op_unlink(fuse_req_t req, fuse_ino_t parent, const char *name) { - struct fuse_entry_param e; - guint64 ino; + int rc = dbfs_unlink(parent, name, 0); + if (rc) + fuse_reply_err(req, rc); +} + +static int dbfs_chk_empty(struct dbfs_dirent *de, void *userdata) +{ + if ((de->namelen == 1) && (!memcmp(de->name, ".", 1))) + return 0; + if ((de->namelen == 2) && (!memcmp(de->name, "..", 2))) + return 0; + return ENOTEMPTY; +} + +static void dbfs_op_rmdir(fuse_req_t req, fuse_ino_t parent, const char *name) +{ + guint64 ino_n; int rc; + DBT val; - /* lookup inode in parent directory */ - rc = dbfs_lookup(parent, name, &ino); - if (rc) { - fuse_reply_err(req, rc); - return; - } + /* get inode number associated with name */ + rc = dbfs_lookup(parent, name, &ino_n); + if (rc) + goto err_out; - /* send reply; timeout of 2.0 is just a guess */ + /* read dir associated with name */ + rc = dbfs_read_dir(ino_n, &val); + if (rc) + goto err_out; - memset(&e, 0, sizeof(e)); - e.ino = ino; - e.attr_timeout = 2.0; - e.entry_timeout = 2.0; + /* make sure dir only contains "." and ".." */ + rc = dbfs_dir_foreach(val.data, dbfs_chk_empty, NULL); + free(val.data); - fuse_reply_entry(req, &e); + /* if dbfs_chk_empty() returns non-zero, dir is not empty */ + if (rc) + goto err_out; + + /* dir is empty, go ahead and unlink */ + rc = dbfs_unlink(parent, name, DBFS_UNLINK_DIR); + if (rc) + goto err_out; + + return; + +err_out: + fuse_reply_err(req, rc); } static void dbfs_op_opendir(fuse_req_t req, fuse_ino_t ino, @@ -186,57 +237,6 @@ static void dbfs_op_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, free(b.p); } -static int dbfs_chk_empty(struct dbfs_dirent *de, void *userdata) -{ - if ((de->namelen == 1) && (!memcmp(de->name, ".", 1))) - return 0; - if ((de->namelen == 2) && (!memcmp(de->name, "..", 2))) - return 0; - return ENOTEMPTY; -} - -static void dbfs_op_unlink(fuse_req_t req, fuse_ino_t parent, const char *name) -{ - int rc = dbfs_unlink(parent, name, 0); - if (rc) - fuse_reply_err(req, rc); -} - -static void dbfs_op_rmdir(fuse_req_t req, fuse_ino_t parent, const char *name) -{ - guint64 ino_n; - int rc; - DBT val; - - /* get inode number associated with name */ - rc = dbfs_lookup(parent, name, &ino_n); - if (rc) - goto err_out; - - /* read dir associated with name */ - rc = dbfs_read_dir(ino_n, &val); - if (rc) - goto err_out; - - /* make sure dir only contains "." and ".." */ - rc = dbfs_dir_foreach(val.data, dbfs_chk_empty, NULL); - free(val.data); - - /* if dbfs_chk_empty() returns non-zero, dir is not empty */ - if (rc) - goto err_out; - - /* dir is empty, go ahead and unlink */ - rc = dbfs_unlink(parent, name, DBFS_UNLINK_DIR); - if (rc) - goto err_out; - - return; - -err_out: - fuse_reply_err(req, rc); -} - #if 0 static void hello_ll_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) |