From 45d077860ce1a4779d2fd1beb2408ad1115cfaf0 Mon Sep 17 00:00:00 2001 From: szaka Date: Sun, 20 Jan 2008 13:14:49 +0000 Subject: [PATCH] factor out setup_logging() --- src/ntfs-3g.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index 0eac4996..da9b1905 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -2252,6 +2252,29 @@ err: goto out; } +static void setup_logging(char *parsed_options) +{ + if (!ctx->no_detach) { + if (daemon(0, ctx->debug)) + ntfs_log_error("Failed to daemonize.\n"); + else if (!ctx->debug) { +#ifndef DEBUG + ntfs_log_set_handler(ntfs_log_handler_syslog); + /* Override default libntfs identify. */ + openlog(EXEC_NAME, LOG_PID, LOG_DAEMON); +#endif + } + } + + ntfs_log_info("Version %s\n", VERSION); + ntfs_log_info("Mounted %s (%s, label \"%s\", NTFS %d.%d)\n", + opts.device, (ctx->ro) ? "Read-Only" : "Read-Write", + ctx->vol->vol_name, ctx->vol->major_ver, + ctx->vol->minor_ver); + ntfs_log_info("Cmdline options: %s\n", opts.options); + ntfs_log_info("Mount options: %s\n", parsed_options); +} + int main(int argc, char *argv[]) { char *parsed_options = NULL; @@ -2316,25 +2339,7 @@ int main(int argc, char *argv[]) if (S_ISBLK(sbuf.st_mode) && (fstype == FSTYPE_FUSE)) ntfs_log_info(fuse26_kmod_msg); #endif - if (!ctx->no_detach) { - if (daemon(0, ctx->debug)) - ntfs_log_error("Failed to daemonize.\n"); - else if (!ctx->debug) { -#ifndef DEBUG - ntfs_log_set_handler(ntfs_log_handler_syslog); - /* Override default libntfs identify. */ - openlog(EXEC_NAME, LOG_PID, LOG_DAEMON); -#endif - } - } - - ntfs_log_info("Version %s\n", VERSION); - ntfs_log_info("Mounted %s (%s, label \"%s\", NTFS %d.%d)\n", - opts.device, (ctx->ro) ? "Read-Only" : "Read-Write", - ctx->vol->vol_name, ctx->vol->major_ver, - ctx->vol->minor_ver); - ntfs_log_info("Cmdline options: %s\n", opts.options); - ntfs_log_info("Mount options: %s\n", parsed_options); + setup_logging(parsed_options); fuse_loop(fh);