From a9855dedea4ad20754077cac46e93e31a70c89fb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 10 Mar 2001 19:50:36 +0000 Subject: Sync up Urbans changes from 2.2 into HEAD. Jeremy. (This used to be commit d0fcd9144363acb4136af9d82f25980bd837d73c) --- source3/client/smbmnt.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- source3/client/smbmount.c | 5 ++++- 2 files changed, 46 insertions(+), 5 deletions(-) (limited to 'source3/client') diff --git a/source3/client/smbmnt.c b/source3/client/smbmnt.c index b7e30c3967..209d50ab81 100644 --- a/source3/client/smbmnt.c +++ b/source3/client/smbmnt.c @@ -9,6 +9,7 @@ #include "includes.h" #include +#include #include #include @@ -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"); diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c index 3c0b132937..9b92cf261a 100644 --- a/source3/client/smbmount.c +++ b/source3/client/smbmount.c @@ -641,6 +641,7 @@ static void usage(void) "Options: username= SMB username password= SMB password + credentials= file with username/password netbiosname= source NetBIOS name uid= mount uid or username gid= mount gid or groupname @@ -652,7 +653,9 @@ static void usage(void) workgroup= workgroup on destination sockopt= TCP socket options scope= NetBIOS scope - credentials= file with username/password + iocharset= Linux charset (iso8859-1, utf8) + codepage= server codepage (cp850) + ttl= dircache time to live guest don't prompt for a password ro mount read-only rw mount read-write -- cgit