From 1193a39c0869a3608f22472735bcffdcccb6b2a5 Mon Sep 17 00:00:00 2001 From: Reuben Hawkins Date: Fri, 20 May 2011 07:01:38 -0700 Subject: cleaning up warnings fprintf(stderr, whatever); -> fprintf(stderr, "%s", whatever); checking return values on chdir and lockf where we weren't already modified: example/cusexmp.c modified: example/fioclient.c modified: util/fusermount.c --- util/fusermount.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'util') diff --git a/util/fusermount.c b/util/fusermount.c index 21e55f1..691e4fb 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -127,7 +127,13 @@ static int lock_umount(void) static void unlock_umount(int mtablock) { if (mtablock >= 0) { - lockf(mtablock, F_ULOCK, 0); + int res; + + res = lockf(mtablock, F_ULOCK, 0); + if (res < 0) { + fprintf(stderr, "%s: error releasing lock: %s\n", + progname, strerror(errno)); + } close(mtablock); } } @@ -438,10 +444,15 @@ static int unmount_fuse_locked(const char *mnt, int quiet, int lazy) } out: - chdir("/"); if (res == -1) return -1; + res = chdir("/"); + if (res == -1) { + fprintf(stderr, "%s: failed to chdir to '/'\n", progname); + return -1; + } + return fuse_mnt_remove_mount(progname, mnt); } @@ -1074,13 +1085,18 @@ static int mount_fuse(const char *mnt, const char *opts) } else restore_privs(); - chdir("/"); if (mountpoint_fd != -1) close(mountpoint_fd); if (res == -1) goto fail_close_fd; + res = chdir("/"); + if (res == -1) { + fprintf(stderr, "%s: failed to chdir to '/'\n", progname); + goto fail_close_fd; + } + if (geteuid() == 0) { res = add_mount(source, mnt, type, mnt_opts); if (res == -1) { @@ -1279,7 +1295,11 @@ int main(int argc, char *argv[]) btw We don't want to use daemon() function here because it forks and messes with the file descriptors. */ setsid(); - chdir("/"); + res = chdir("/"); + if (res == -1) { + fprintf(stderr, "%s: failed to chdir to '/'\n", progname); + exit(1); + } sigfillset(&sigset); sigprocmask(SIG_BLOCK, &sigset, NULL); -- cgit v1.2.3