hurdextras-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

smbfs smbfs.c smbnetfs.c


From: Ludovic Courtès
Subject: smbfs smbfs.c smbnetfs.c
Date: Sun, 04 Mar 2012 14:23:24 +0000

CVSROOT:        /sources/hurdextras
Module name:    smbfs
Changes by:     Ludovic Courtès <civodul>       12/03/04 14:23:24

Modified files:
        .              : smbfs.c smbnetfs.c 

Log message:
        Add default argument values; improve error reports.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/smbfs/smbfs.c?cvsroot=hurdextras&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/smbfs/smbnetfs.c?cvsroot=hurdextras&r1=1.5&r2=1.6

Patches:
Index: smbfs.c
===================================================================
RCS file: /sources/hurdextras/smbfs/smbfs.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- smbfs.c     4 Mar 2012 13:54:00 -0000       1.6
+++ smbfs.c     4 Mar 2012 14:23:24 -0000       1.7
@@ -22,8 +22,9 @@
 #include "smb.h"
 #include <stdio.h>
 
-static char doc[] = "smbfs - smb filesystem translator" \
-    "\vSHARE Specify the resource in the form smb://[WORKGROUP/]HOST/SHARE";
+static char doc[] = "smbfs - SMB file system translator" \
+  "\vSHARE specifies an SMB directory in the form "
+  "`smb://[WORKGROUP/]HOST/SHARE'.";
 static char args_doc[] = "SHARE";
 
 
@@ -32,11 +33,11 @@
 extern void smbfs_terminate ();
 static struct argp_option options[] = 
 {
-       {"server",'s',"SERVER",0,"server samba"},
-       {"resource",'r',"RESOURCE",0,"resource to access"},
-       {"password",'p',"PWD",0,"password to use"},
-       {"username",'u',"USR",0,"username to use"},
-       {"workgroup",'w',"WKG",0,"workgroup to use"},
+       {"server",'s',"SERVER",0, "SMB server"},
+       {"resource",'r',"RESOURCE",0, "directory to access"},
+       {"password",'p',"PWD",0, "password to use (default: empty password)"},
+       {"username",'u',"USR",0, "user name to use (default: `$USER')"},
+       {"workgroup",'w',"WKG",0, "workgroup to use (default: `WORKGROUP')"},
        {0}
 };
 static error_t parse_opt(int key, char *arg, struct argp_state *state)
@@ -76,27 +77,24 @@
   mach_port_t bootstrap;
   int err;
 
-  credentials.server = 0;
-  credentials.share = 0;
-  credentials.workgroup = 0;
-  credentials.username = 0;
-  credentials.password = 0;
+  /* Default user name.  */
+  credentials.username = getenv ("USER");
 
-  argp_parse(&smb_argp, argc, argv, 0, 0, &credentials);
+  argp_parse (&smb_argp, argc, argv, 0, 0, &credentials);
 
   if(!credentials.server  || !credentials.share || !credentials.workgroup
      || !credentials.username || !credentials.password)
-    error (EXIT_FAILURE, EINVAL, "You must specify server - share - workgroup 
- username "
-           " - password !!!\n");
-
-  task_get_bootstrap_port (mach_task_self (), &bootstrap);
-  if (bootstrap == MACH_PORT_NULL)
-    error (EXIT_FAILURE, errno, "You need to run this as a translator!");
+    error (EXIT_FAILURE, 0, "Please specify a server, share, workgroup, "
+          "user name, and password.");
 
   err = init_smb ();  
 
   if (err < 0)
-    error (EXIT_FAILURE, errno, "Error init_smb\n");
+    error (EXIT_FAILURE, errno, "failed to initialize SMB client");
+
+  task_get_bootstrap_port (mach_task_self (), &bootstrap);
+  if (bootstrap == MACH_PORT_NULL)
+    error (EXIT_FAILURE, 0, "Must be started as a translator.");
 
   netfs_init();
   netfs_startup(bootstrap, 0);

Index: smbnetfs.c
===================================================================
RCS file: /sources/hurdextras/smbfs/smbnetfs.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- smbnetfs.c  14 Jul 2009 17:44:31 -0000      1.5
+++ smbnetfs.c  4 Mar 2012 14:23:24 -0000       1.6
@@ -35,7 +35,12 @@
 #define DIRENT_LEN(name_len)    ((DIRENT_NAME_OFFS + (name_len) + 1 \
                                + (DIRENT_ALIGN - 1)) & ~(DIRENT_ALIGN - 1))
 
-struct smb_credentials credentials;
+struct smb_credentials credentials =
+  {
+    .workgroup = "WORKGROUP",
+    .password = ""
+  };
+
 static volatile struct mapped_time_value *maptime;
 static struct mutex smb_mutex;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]