Sync up Urbans changes from 2.2 into HEAD.
authorJeremy Allison <jra@samba.org>
Sat, 10 Mar 2001 19:50:36 +0000 (19:50 +0000)
committerJeremy Allison <jra@samba.org>
Sat, 10 Mar 2001 19:50:36 +0000 (19:50 +0000)
Jeremy.

source/client/smbmnt.c
source/client/smbmount.c

index b7e30c3967f5ef7eaa366b5f329fa441667df0b1..209d50ab81064b8dfa51b89ed359c347a233ec79 100644 (file)
@@ -9,6 +9,7 @@
 #include "includes.h"
 
 #include <mntent.h>
+#include <sys/utsname.h>
 
 #include <asm/types.h>
 #include <asm/posix_types.h>
@@ -30,18 +31,21 @@ static int mount_ro;
 static unsigned mount_fmask;
 static unsigned mount_dmask;
 static int user_mount;
+static char *options;
 
 static void
 help(void)
 {
         printf("\n");
-        printf("usage: smbmnt mount-point [options]\n");
+        printf("Usage: smbmnt mount-point [options]\n");
+       printf("Version %s\n\n",VERSION);
         printf("-s share       share name on server\n"
                "-r             mount read-only\n"
                "-u uid         mount as uid\n"
                "-g gid         mount as gid\n"
                "-f mask        permission mask for files\n"
                "-d mask        permission mask for directories\n"
+               "-o options     name=value, list of options\n"
                "-h             print this help text\n");
 }
 
@@ -50,7 +54,7 @@ parse_args(int argc, char *argv[], struct smb_mount_data *data, char **share)
 {
         int opt;
 
-        while ((opt = getopt (argc, argv, "s:u:g:rf:d:")) != EOF)
+        while ((opt = getopt (argc, argv, "s:u:g:rf:d:o:")) != EOF)
        {
                 switch (opt)
                {
@@ -76,6 +80,9 @@ parse_args(int argc, char *argv[], struct smb_mount_data *data, char **share)
                 case 'd':
                         mount_dmask = strtol(optarg, NULL, 8);
                         break;
+               case 'o':
+                       options = optarg;
+                       break;
                 default:
                         return -1;
                 }
@@ -129,6 +136,38 @@ static int mount_ok(char *mount_point)
         return 0;
 }
 
+/* Tries to mount using the appropriate format. For 2.2 the struct,
+   for 2.4 the ascii version. */
+static int
+do_mount(char *share_name, unsigned int flags, struct smb_mount_data *data)
+{
+       pstring opts;
+       struct utsname uts;
+       char *release, *major, *minor;
+       char *data1, *data2;
+
+       uname(&uts);
+       release = uts.release;
+       major = strsep(&release, ".");
+       minor = strsep(&release, ".");
+       if (major && minor && atoi(major) == 2 && atoi(minor) < 4) {
+               /* < 2.4, assume struct */
+               data1 = (char *) data;
+               data2 = opts;
+       } else {
+               /* >= 2.4, assume ascii but fall back on struct */
+               data1 = opts;
+               data2 = (char *) data;
+       }
+
+       slprintf(opts, sizeof(opts),
+                "version=7,uid=%d,gid=%d,file_mode=0%o,dir_mode=0%o,%s",
+                data->uid, data->gid, data->file_mode, data->dir_mode,options);
+       if (mount(share_name, ".", "smbfs", flags, data1) == 0)
+               return 0;
+       return mount(share_name, ".", "smbfs", flags, data2);
+}
+
  int main(int argc, char *argv[])
 {
        char *mount_point, *share_name = NULL;
@@ -205,8 +244,7 @@ static int mount_ok(char *mount_point)
 
        if (mount_ro) flags |= MS_RDONLY;
 
-       if (mount(share_name, ".", "smbfs", flags, (char *)&data) < 0)
-       {
+       if (do_mount(share_name, flags, &data) < 0) {
                switch (errno) {
                case ENODEV:
                        fprintf(stderr, "ERROR: smbfs filesystem not supported by the kernel\n");
index 3c0b13293796499105d369b5aa732af4229a3def..9b92cf261a0ad07ef7775c4f28f83ec3692bb4e1 100644 (file)
@@ -641,6 +641,7 @@ static void usage(void)
 "Options:
       username=<arg>                  SMB username
       password=<arg>                  SMB password
+      credentials=<filename>          file with username/password
       netbiosname=<arg>               source NetBIOS name
       uid=<arg>                       mount uid or username
       gid=<arg>                       mount gid or groupname
@@ -652,7 +653,9 @@ static void usage(void)
       workgroup=<arg>                 workgroup on destination
       sockopt=<arg>                   TCP socket options
       scope=<arg>                     NetBIOS scope
-      credentials=<filename>          file with username/password
+      iocharset=<arg>                 Linux charset (iso8859-1, utf8)
+      codepage=<arg>                  server codepage (cp850)
+      ttl=<arg>                       dircache time to live
       guest                           don't prompt for a password
       ro                              mount read-only
       rw                              mount read-write