Added -u option. - susmb - mounting of SMB/CIFS shares via FUSE
 (HTM) git clone git://git.codemadness.org/susmb
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 0f068c22353a61db22df334ef605f19ef213cd49
 (DIR) parent 3878c72e464c69e0a6a41263f67e9150b6ea648c
 (HTM) Author: Geoff Johnstone <qwerty@acm.org>
       Date:   Mon, 15 Jun 2009 19:58:22 +0100
       
       Added -u option.
       
       Diffstat:
         M options.c                           |      11 ++++++++++-
         M options.h                           |       3 ++-
         M usmb.c                              |      29 +++++++++++++++++------------
       
       3 files changed, 29 insertions(+), 14 deletions(-)
       ---
 (DIR) diff --git a/options.c b/options.c
       @@ -29,6 +29,7 @@ static gboolean version = FALSE;
        static gchar *conffile = NULL;
        static gboolean debug = FALSE;
        static gboolean nofork = FALSE;
       +static gboolean umount = FALSE;
        static gchar **remaining = NULL;
        
        
       @@ -66,6 +67,12 @@ static GOptionEntry entries[] = {
            .arg_data = &nofork,
            .description = "Foreground operation" },
        
       +  { .long_name = "unmount",
       +    .short_name = 'u',
       +    .arg = G_OPTION_ARG_NONE,
       +    .arg_data = &umount,
       +    .description = "Unmount the given filesystem" },
       +
          { .long_name = G_OPTION_REMAINING,
            .short_name = 0,
            .arg = G_OPTION_ARG_STRING_ARRAY,
       @@ -77,7 +84,8 @@ static GOptionEntry entries[] = {
        
        
        bool parse_args (int *argc, char ***argv,
       -                 const char **mountid, const char **out_conffile)
       +                 const char **mountid, const char **out_conffile,
       +                 bool *out_umount)
        {
          GError *error = NULL;
        
       @@ -111,6 +119,7 @@ bool parse_args (int *argc, char ***argv,
            return false;
          }
        
       +  *out_umount = umount;
          *mountid = remaining[0];
          g_free (remaining);
          DEBUG (fprintf (stderr, "Mount ID: %s\n", *mountid));
 (DIR) diff --git a/options.h b/options.h
       @@ -18,7 +18,8 @@
          #define OPTIONS_H
        
          bool parse_args (int *argc, char ***argv,
       -                   const char **mountid, const char **out_conffile) MUSTCHECK;
       +                   const char **mountid, const char **out_conffile,
       +                   bool *out_umount) MUSTCHECK;
          void build_fuse_args (const char *options, const char *mountpoint,
                                int *out_argc, char ***out_argv);
        
 (DIR) diff --git a/usmb.c b/usmb.c
       @@ -265,7 +265,9 @@ static bool get_context (void)
        int main (int argc, char **argv)
        {
          const char *conffile, *mountid;
       +  bool umount;
          char *sharename = NULL;
       +  int ret = EXIT_FAILURE;
        
          if (sizeof (uint64_t) < sizeof (uintptr_t))
          {
       @@ -279,32 +281,35 @@ int main (int argc, char **argv)
            conffile = conf;
          }
        
       -  if (!parse_args (&argc, &argv, &mountid, &conffile))
       +  if (!parse_args (&argc, &argv, &mountid, &conffile, &umount))
            return EXIT_FAILURE;
        
       -  show_about (stdout);
       +  if (!umount)
       +    show_about (stdout);
        
          if (!conffile_get_mount (conffile, mountid,
                                   &server, &sharename, &mountpoint, &options,
                                   &domain, &username, &password))
            return EXIT_FAILURE;
        
       -  if (!create_share_name (server, sharename) || !get_context())
       +  if (umount)
          {
       -    free_strings (sharename);
       -    return EXIT_FAILURE;
       +    execlp ("fusermount", "fusermount", "-u", mountpoint, NULL);
       +    perror ("Failed to execute fusermount");
          }
        
       -  DEBUG (fprintf (stderr, "Username: %s\\%s\n", domain, username));
       +  else if (create_share_name (server, sharename) && get_context())
       +  {
       +    DEBUG (fprintf (stderr, "Username: %s\\%s\n", domain, username));
        
       -  int fuse_argc;
       -  char **fuse_argv;
       -  build_fuse_args (options, mountpoint, &fuse_argc, &fuse_argv);
       -  int ret = fuse_main (fuse_argc, fuse_argv, &fuse_ops, NULL);
       +    int fuse_argc;
       +    char **fuse_argv;
       +    build_fuse_args (options, mountpoint, &fuse_argc, &fuse_argv);
       +    ret = fuse_main (fuse_argc, fuse_argv, &fuse_ops, NULL);
       +    destroy_smb_context (ctx, 1);
       +  }
        
       -  destroy_smb_context (ctx, 1);
          free_strings (sharename);
       -
          return ret;
        }