summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Schubert <bernd.schubert@fastmail.fm>2010-06-15 18:49:03 +0200
committerBernd Schubert <bernd.schubert@fastmail.fm>2010-06-15 18:49:03 +0200
commitc36e32592ab3768bbaa71ab0f480bf52fc0409e9 (patch)
treed5b456e45664418cc9644109e694b33297ae78c6
parented3b74aacf14b4fe1247dfa286e075a3744950af (diff)
downloadunionfs-fuse-c36e32592ab3768bbaa71ab0f480bf52fc0409e9.tar.gz
Print path names on function tracing.
-rw-r--r--src/cow.c8
-rw-r--r--src/cow_utils.c12
-rw-r--r--src/findbranch.c6
-rw-r--r--src/general.c14
-rw-r--r--src/readdir.c8
-rw-r--r--src/rmdir.c6
-rw-r--r--src/string.c6
-rw-r--r--src/unionfs.c47
-rw-r--r--src/unlink.c6
9 files changed, 58 insertions, 55 deletions
diff --git a/src/cow.c b/src/cow.c
index a5a2f4c..2d8af6d 100644
--- a/src/cow.c
+++ b/src/cow.c
@@ -71,7 +71,7 @@ static int do_create(const char *path, int nbranch_ro, int nbranch_rw) {
* nbranch for an other COW operation.
*/
int path_create(const char *path, int nbranch_ro, int nbranch_rw) {
- DBG_IN();
+ DBG("%s\n", path);
if (!uopt.cow_enabled) return 0;
@@ -110,7 +110,7 @@ int path_create(const char *path, int nbranch_ro, int nbranch_rw) {
* i.e. it might be a filename.
*/
int path_create_cutlast(const char *path, int nbranch_ro, int nbranch_rw) {
- DBG_IN();
+ DBG("%s\n", path);
char *dname = u_dirname(path);
if (dname == NULL)
@@ -125,7 +125,7 @@ int path_create_cutlast(const char *path, int nbranch_ro, int nbranch_rw) {
* initiate the cow-copy action
*/
int cow_cp(const char *path, int branch_ro, int branch_rw) {
- DBG_IN();
+ DBG("%s\n", path);
// create the path to the file
path_create_cutlast(path, branch_ro, branch_rw);
@@ -182,7 +182,7 @@ int cow_cp(const char *path, int branch_ro, int branch_rw) {
* copy a directory between branches (includes all contents of the directory)
*/
int copy_directory(const char *path, int branch_ro, int branch_rw) {
- DBG_IN();
+ DBG("%s\n", path);
/* create the directory on the destination branch */
int res = path_create(path, branch_ro, branch_rw);
diff --git a/src/cow_utils.c b/src/cow_utils.c
index 0a64d0e..b798a61 100644
--- a/src/cow_utils.c
+++ b/src/cow_utils.c
@@ -57,7 +57,7 @@
**/
int setfile(const char *path, struct stat *fs)
{
- DBG_IN();
+ DBG("%s\n", path);
struct utimbuf ut;
int rval;
@@ -115,7 +115,7 @@ int setfile(const char *path, struct stat *fs)
**/
static int setlink(const char *path, struct stat *fs)
{
- DBG_IN();
+ DBG("%s\n", path);
if (lchown(path, fs->st_uid, fs->st_gid)) {
if (errno != EPERM) {
@@ -132,7 +132,7 @@ static int setlink(const char *path, struct stat *fs)
**/
int copy_file(struct cow *cow)
{
- DBG_IN();
+ DBG("from %s to %s\n", cow->from_path, cow->to_path);
static char buf[MAXBSIZE];
struct stat to_stat, *fs;
@@ -236,7 +236,7 @@ int copy_file(struct cow *cow)
*/
int copy_link(struct cow *cow)
{
- DBG_IN();
+ DBG("from %s to %s\n", cow->from_path, cow->to_path);
int len;
char link[PATHLEN_MAX];
@@ -262,7 +262,7 @@ int copy_link(struct cow *cow)
**/
int copy_fifo(struct cow *cow)
{
- DBG_IN();
+ DBG("from %s to %s\n", cow->from_path, cow->to_path);
if (mkfifo(cow->to_path, cow->stat->st_mode)) {
usyslog(LOG_WARNING, "mkfifo: %s", cow->to_path);
@@ -277,7 +277,7 @@ int copy_fifo(struct cow *cow)
*/
int copy_special(struct cow *cow)
{
- DBG_IN();
+ DBG("from %s to %s\n", cow->from_path, cow->to_path);
if (mknod(cow->to_path, cow->stat->st_mode, cow->stat->st_rdev)) {
usyslog(LOG_WARNING, "mknod: %s", cow->to_path);
diff --git a/src/findbranch.c b/src/findbranch.c
index d80f262..5111c71 100644
--- a/src/findbranch.c
+++ b/src/findbranch.c
@@ -54,7 +54,7 @@
* Find a branch that has "path". Return the branch number.
*/
static int find_branch(const char *path, searchflag_t flag) {
- DBG_IN();
+ DBG("%s\n", path);
int i = 0;
for (i = 0; i < uopt.nbranches; i++) {
@@ -100,7 +100,7 @@ static int find_branch(const char *path, searchflag_t flag) {
* Find a ro or rw branch.
*/
int find_rorw_branch(const char *path) {
- DBG_IN();
+ DBG("%s\n", path);
return find_branch(path, RWRO);
}
@@ -185,7 +185,7 @@ int find_rw_branch_cutlast(const char *path) {
* and a directory is to be copied from ro- to rw-branch.
*/
int find_rw_branch_cow(const char *path) {
- DBG_IN();
+ DBG("%s\n", path);
int branch_rorw = find_rorw_branch(path);
diff --git a/src/general.c b/src/general.c
index 6c5c559..5a7ce89 100644
--- a/src/general.c
+++ b/src/general.c
@@ -55,7 +55,7 @@ static int filedir_hidden(const char *path) {
* check if any dir or file within path is hidden
*/
int path_hidden(const char *path, int branch) {
- DBG_IN();
+ DBG("%s\n", path);
if (!uopt.cow_enabled) return false;
@@ -91,7 +91,7 @@ int path_hidden(const char *path, int branch) {
* If maxbranch == -1, try to delete it in all branches.
*/
int remove_hidden(const char *path, int maxbranch) {
- DBG_IN();
+ DBG("%s\n", path);
if (!uopt.cow_enabled) return 0;
@@ -120,7 +120,7 @@ int remove_hidden(const char *path, int maxbranch) {
* return proper types given by filetype_t
*/
filetype_t path_is_dir(const char *path) {
- DBG_IN();
+ DBG("%s\n", path);
struct stat buf;
@@ -135,7 +135,7 @@ filetype_t path_is_dir(const char *path) {
* Create a file or directory that hides path below branch_rw
*/
static int do_create_whiteout(const char *path, int branch_rw, enum whiteout mode) {
- DBG_IN();
+ DBG("%s\n", path);
char metapath[PATHLEN_MAX];
@@ -165,7 +165,7 @@ static int do_create_whiteout(const char *path, int branch_rw, enum whiteout mod
* Create a file that hides path below branch_rw
*/
int hide_file(const char *path, int branch_rw) {
- DBG_IN();
+ DBG("%s\n", path);
return do_create_whiteout(path, branch_rw, WHITEOUT_FILE);
}
@@ -173,7 +173,7 @@ int hide_file(const char *path, int branch_rw) {
* Create a directory that hides path below branch_rw
*/
int hide_dir(const char *path, int branch_rw) {
- DBG_IN();
+ DBG("%s\n", path);
return do_create_whiteout(path, branch_rw, WHITEOUT_DIR);
}
@@ -182,7 +182,7 @@ int hide_dir(const char *path, int branch_rw) {
* if the same file/dir does exist in a lower branch
*/
int maybe_whiteout(const char *path, int branch_rw, enum whiteout mode) {
- DBG_IN();
+ DBG("%s\n", path);
// we are not interested in the branch itself, only if it exists at all
if (find_rorw_branch(path) != -1) {
diff --git a/src/readdir.c b/src/readdir.c
index cc1c072..c01ed5e 100644
--- a/src/readdir.c
+++ b/src/readdir.c
@@ -65,7 +65,7 @@ static bool hide_meta_files(int branch, const char *path, struct dirent *de)
* Warning: If fname has the tag, fname gets modified.
*/
static bool is_hiding(struct hashtable *hides, char *fname) {
- DBG_IN();
+ DBG("%s\n", fname);
char *tag;
@@ -90,7 +90,7 @@ static bool is_hiding(struct hashtable *hides, char *fname) {
* Read whiteout files
*/
static void read_whiteouts(const char *path, struct hashtable *whiteouts, int branch) {
- DBG_IN();
+ DBG("%s\n", path);
char p[PATHLEN_MAX];
if (BUILD_PATH(p, uopt.branches[branch].path, METADIR, path)) return;
@@ -110,7 +110,7 @@ static void read_whiteouts(const char *path, struct hashtable *whiteouts, int br
* unionfs-fuse readdir function
*/
int unionfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
- DBG_IN();
+ DBG("%s\n", path);
(void)offset;
(void)fi;
@@ -199,7 +199,7 @@ out:
*/
int dir_not_empty(const char *path) {
- DBG_IN();
+ DBG("%s\n", path);
int i = 0;
int rc = 0;
diff --git a/src/rmdir.c b/src/rmdir.c
index e5212c9..b9190a8 100644
--- a/src/rmdir.c
+++ b/src/rmdir.c
@@ -38,7 +38,7 @@
* we can really delete the file.
*/
static int rmdir_rw(const char *path, int branch_rw) {
- DBG_IN();
+ DBG("%s\n", path);
char p[PATHLEN_MAX];
if (BUILD_PATH(p, uopt.branches[branch_rw].path, path)) return ENAMETOOLONG;
@@ -56,7 +56,7 @@ static int rmdir_rw(const char *path, int branch_rw) {
* lower level directory.
*/
static int rmdir_ro(const char *path, int branch_ro) {
- DBG_IN();
+ DBG("%s\n", path);
// find a writable branch above branch_ro
int branch_rw = find_lowest_rw_branch(branch_ro);
@@ -83,7 +83,7 @@ static int rmdir_ro(const char *path, int branch_ro) {
* rmdir() call
*/
int unionfs_rmdir(const char *path) {
- DBG_IN();
+ DBG("%s\n", path);
if (dir_not_empty(path)) return -ENOTEMPTY;
diff --git a/src/string.c b/src/string.c
index 8c218fe..b36058d 100644
--- a/src/string.c
+++ b/src/string.c
@@ -29,7 +29,7 @@
* Check if the given fname suffixes the hide tag
*/
char *whiteout_tag(const char *fname) {
- DBG_IN();
+ DBG("%s\n", fname);
char *tag = strstr(fname, HIDETAG);
@@ -137,7 +137,7 @@ int build_path(char *path, int max_len, const char *callfunc, int line, ...) {
* implementation
*/
char *u_dirname(const char *path) {
- DBG_IN();
+ DBG("%s\n", path);
char *ret = strdup(path);
if (ret == NULL) {
@@ -164,7 +164,7 @@ char *u_dirname(const char *path) {
* str needs to NULL terminated
*/
static unsigned int elfhash(const char *str) {
- DBG_IN();
+ DBG("%s\n", str);
unsigned int hash = 0;
diff --git a/src/unionfs.c b/src/unionfs.c
index 091f00d..e3ed9b8 100644
--- a/src/unionfs.c
+++ b/src/unionfs.c
@@ -26,6 +26,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
+#include <inttypes.h>
#ifdef linux
#include <sys/vfs.h>
#else
@@ -71,7 +72,7 @@ static struct fuse_opt unionfs_opts[] = {
static int unionfs_chmod(const char *path, mode_t mode) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rw_branch_cow(path);
if (i == -1) return -errno;
@@ -86,7 +87,7 @@ static int unionfs_chmod(const char *path, mode_t mode) {
}
static int unionfs_chown(const char *path, uid_t uid, gid_t gid) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rw_branch_cow(path);
if (i == -1) return -errno;
@@ -105,7 +106,7 @@ static int unionfs_chown(const char *path, uid_t uid, gid_t gid) {
* libfuse will call this to create regular files
*/
static int unionfs_create(const char *path, mode_t mode, struct fuse_file_info *fi) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rw_branch_cutlast(path);
if (i == -1) return -errno;
@@ -128,6 +129,7 @@ static int unionfs_create(const char *path, mode_t mode, struct fuse_file_info *
fi->fh = res;
remove_hidden(path, i);
+ DBG("fd = %" PRIx64 "\n", fi->fh);
return 0;
}
@@ -138,7 +140,7 @@ static int unionfs_create(const char *path, mode_t mode, struct fuse_file_info *
* which flush the data/metadata on close()
*/
static int unionfs_flush(const char *path, struct fuse_file_info *fi) {
- DBG_IN();
+ DBG("%"PRIx64"\n", fi->fh);
if (uopt.stats_enabled && strcmp(path, STATS_FILENAME) == 0) return 0;
@@ -161,7 +163,7 @@ static int unionfs_flush(const char *path, struct fuse_file_info *fi) {
* Just a stub. This method is optional and can safely be left unimplemented
*/
static int unionfs_fsync(const char *path, int isdatasync, struct fuse_file_info *fi) {
- DBG_IN();
+ DBG("%"PRIx64"\n", fi->fh);
if (uopt.stats_enabled && strcmp(path, STATS_FILENAME) == 0) return 0;
@@ -182,7 +184,7 @@ static int unionfs_fsync(const char *path, int isdatasync, struct fuse_file_info
}
static int unionfs_getattr(const char *path, struct stat *stbuf) {
- DBG_IN();
+ DBG("%s\n", path);
if (uopt.stats_enabled && strcmp(path, STATS_FILENAME) == 0) {
memset(stbuf, 0, sizeof(stbuf));
@@ -235,7 +237,7 @@ static void * unionfs_init(struct fuse_conn_info *conn) {
}
static int unionfs_link(const char *from, const char *to) {
- DBG_IN();
+ DBG("from %s to %s\n", from, to);
// hardlinks do not work across different filesystems so we need a copy of from first
int i = find_rw_branch_cow(from);
@@ -266,7 +268,7 @@ static int unionfs_link(const char *from, const char *to) {
* make already hidden sub-branches visible again.
*/
static int unionfs_mkdir(const char *path, mode_t mode) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rw_branch_cutlast(path);
if (i == -1) return -errno;
@@ -285,7 +287,7 @@ static int unionfs_mkdir(const char *path, mode_t mode) {
}
static int unionfs_mknod(const char *path, mode_t mode, dev_t rdev) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rw_branch_cutlast(path);
if (i == -1) return -errno;
@@ -323,7 +325,7 @@ static int unionfs_mknod(const char *path, mode_t mode, dev_t rdev) {
}
static int unionfs_open(const char *path, struct fuse_file_info *fi) {
- DBG_IN();
+ DBG("%s\n", path);
if (uopt.stats_enabled && strcmp(path, STATS_FILENAME) == 0) {
if ((fi->flags & 3) == O_RDONLY) {
@@ -359,11 +361,12 @@ static int unionfs_open(const char *path, struct fuse_file_info *fi) {
//fi->direct_io = 1;
fi->fh = (unsigned long)fd;
+ DBG("fd = %"PRIx64"\n", fi->fh);
return 0;
}
static int unionfs_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
- DBG_IN();
+ DBG("%"PRIx64"\n", fi->fh);
if (uopt.stats_enabled && strcmp(path, STATS_FILENAME) == 0) {
char out[STATS_SIZE] = "";
@@ -390,7 +393,7 @@ static int unionfs_read(const char *path, char *buf, size_t size, off_t offset,
}
static int unionfs_readlink(const char *path, char *buf, size_t size) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rorw_branch(path);
if (i == -1) return -errno;
@@ -408,7 +411,7 @@ static int unionfs_readlink(const char *path, char *buf, size_t size) {
}
static int unionfs_release(const char *path, struct fuse_file_info *fi) {
- DBG_IN();
+ DBG("%s\n", path);
if (uopt.stats_enabled && strcmp(path, STATS_FILENAME) == 0) return 0;
@@ -424,7 +427,7 @@ static int unionfs_release(const char *path, struct fuse_file_info *fi) {
* all files to the renamed directory on the read-write branch.
*/
static int unionfs_rename(const char *from, const char *to) {
- DBG_IN();
+ DBG("from %s to %s\n", from, to);
bool is_dir = false; // is 'from' a file or directory
@@ -554,7 +557,7 @@ static int statvfs_local(const char *path, struct statvfs *stbuf) {
static int unionfs_statfs(const char *path, struct statvfs *stbuf) {
(void)path;
- DBG_IN();
+ DBG("%s\n", path);
int first = 1;
@@ -619,7 +622,7 @@ static int unionfs_statfs(const char *path, struct statvfs *stbuf) {
}
static int unionfs_symlink(const char *from, const char *to) {
- DBG_IN();
+ DBG("from %s to %s\n", from, to);
int i = find_rw_branch_cutlast(to);
if (i == -1) return -errno;
@@ -637,7 +640,7 @@ static int unionfs_symlink(const char *from, const char *to) {
}
static int unionfs_truncate(const char *path, off_t size) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rw_branch_cow(path);
if (i == -1) return -errno;
@@ -692,7 +695,7 @@ static int unionfs_utimens(const char *path, const struct timespec ts[2]) {
static int unionfs_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
(void)path;
- DBG_IN();
+ DBG("%"PRIx64"\n", fi->fh);
int res = pwrite(fi->fh, buf, size, offset);
if (res == -1) return -errno;
@@ -704,7 +707,7 @@ static int unionfs_write(const char *path, const char *buf, size_t size, off_t o
#ifdef HAVE_SETXATTR
static int unionfs_getxattr(const char *path, const char *name, char *value, size_t size) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rorw_branch(path);
if (i == -1) return -errno;
@@ -720,7 +723,7 @@ static int unionfs_getxattr(const char *path, const char *name, char *value, siz
}
static int unionfs_listxattr(const char *path, char *list, size_t size) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rorw_branch(path);
if (i == -1) return -errno;
@@ -736,7 +739,7 @@ static int unionfs_listxattr(const char *path, char *list, size_t size) {
}
static int unionfs_removexattr(const char *path, const char *name) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rw_branch_cow(path);
if (i == -1) return -errno;
@@ -752,7 +755,7 @@ static int unionfs_removexattr(const char *path, const char *name) {
}
static int unionfs_setxattr(const char *path, const char *name, const char *value, size_t size, int flags) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rw_branch_cow(path);
if (i == -1) return -errno;
diff --git a/src/unlink.c b/src/unlink.c
index 74efcf3..ce37016 100644
--- a/src/unlink.c
+++ b/src/unlink.c
@@ -37,7 +37,7 @@
* lower level file.
*/
static int unlink_ro(const char *path, int branch_ro) {
- DBG_IN();
+ DBG("%s\n", path);
// find a writable branch above branch_ro
int branch_rw = find_lowest_rw_branch(branch_ro);
@@ -58,7 +58,7 @@ static int unlink_ro(const char *path, int branch_ro) {
* we can really delete the file.
*/
static int unlink_rw(const char *path, int branch_rw) {
- DBG_IN();
+ DBG("%s\n", path);
char p[PATHLEN_MAX];
if (BUILD_PATH(p, uopt.branches[branch_rw].path, path)) return ENAMETOOLONG;
@@ -73,7 +73,7 @@ static int unlink_rw(const char *path, int branch_rw) {
* unlink() call
*/
int unionfs_unlink(const char *path) {
- DBG_IN();
+ DBG("%s\n", path);
int i = find_rorw_branch(path);
if (i == -1) return errno;