lkml.org 
[lkml]   [1998]   [Jan]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectpatch for smbmount, smbmnt utils
Hi Volker,

I've attached a patch making a minor improvement to the smbmount and
smbmnt utilities. It adds a new '-s share' argument to smbmnt to allow
the share name to be passed (i.e. the name of the service on the SMB
server).

This share name is then used as the dummy "device" for the mount command
and in the mtab entry, so that the user can see which share is mounted
on a particular mount point.

I've tried it out here and it seems to work OK, but if you could take a
look at it and merge it into the Samba sources if all is OK. I'm CC'ing
the kernel list so others can test as well. Patch is against Samba
1.9.18.

Regards,
Bill--- samba-1.9.18/source/smbmount.c.old Mon Jan 5 19:13:44 1998
+++ samba-1.9.18/source/smbmount.c Fri Jan 16 22:28:14 1998
@@ -33,6 +33,7 @@

pstring cur_dir = "\\";
pstring cd_path = "";
+pstring share_name; /* original share name */
extern pstring service;
extern pstring desthost;
extern pstring myname;
@@ -342,7 +343,7 @@
return;
}

- sprintf(mount_command, "smbmnt %s", mount_point);
+ sprintf(mount_command, "smbmnt %s -s %s", mount_point, share_name);

while(next_token(NULL, buf, NULL))
{
@@ -350,7 +351,7 @@
strcat(mount_command, buf);
}

- DEBUG(3,("mount command: %s\n", mount_command));
+ DEBUG(3, ("mount command: %s\n", mount_command));

/*
* Create the background process before trying the mount.
@@ -739,7 +740,11 @@
if (*argv[1] != '-')
{

- strcpy(service,argv[1]);
+ /* Save the name to report on the Unix side */
+ strcpy(share_name, argv[1]);
+ string_replace(share_name, '\\','/');
+
+ strcpy(service, argv[1]);
/* Convert any '/' characters in the service name to '\' characters */
string_replace( service, '/','\\');
argc--;
--- samba-1.9.18/source/smbmnt.c.old Mon Jan 5 17:56:29 1998
+++ samba-1.9.18/source/smbmnt.c Sat Jan 17 12:05:49 1998
@@ -53,18 +53,18 @@
"-f mode permission the files get (octal notation)\n"
"-d mode permission the dirs get (octal notation)\n"
"-P pid connection handler's pid\n\n"
+ "-s share share name on server\n\n"
"-h print this help text\n");
}

static int
-parse_args(int argc, char *argv[], struct smb_mount_data *data)
+parse_args(int argc, char *argv[], struct smb_mount_data *data, char **share)
{
int opt;
struct passwd *pwd;
struct group *grp;

- while ((opt = getopt (argc, argv, "u:g:f:d:"))
- != EOF)
+ while ((opt = getopt (argc, argv, "u:g:f:d:s:")) != EOF)
{
switch (opt)
{
@@ -108,6 +108,9 @@
case 'd':
data->dir_mode = strtol(optarg, NULL, 8);
break;
+ case 's':
+ *share = optarg;
+ break;
default:
return -1;
}
@@ -157,17 +160,13 @@
int
main(int argc, char *argv[])
{
- struct smb_mount_data data;
- struct stat st;
-
- int fd;
- int um;
+ char *mount_point, *share_name = NULL;
+ FILE *mtab;
+ int fd, um;
unsigned int flags;
-
- char *mount_point;
-
- struct mntent ment;
- FILE *mtab;
+ struct smb_mount_data data;
+ struct stat st;
+ struct mntent ment;

progname = argv[0];

@@ -222,7 +221,7 @@
data.file_mode = (S_IRWXU|S_IRWXG|S_IRWXO) & ~um;
data.dir_mode = 0;

- if (parse_args(argc, argv, &data) != 0) {
+ if (parse_args(argc, argv, &data, &share_name) != 0) {
usage();
return -1;
}
@@ -239,15 +238,14 @@

flags = MS_MGC_VAL;

- if (mount(NULL, mount_point, "smbfs",
- flags, (char *)&data) < 0) {
+ if (mount(share_name, mount_point, "smbfs", flags, (char *)&data) < 0)
+ {
perror("mount error");
- printf("Please look at smbmount's manual page for "
- "possible reasons\n");
+ printf("Please refer to the smbmnt(8) manual page\n");
return -1;
}

- ment.mnt_fsname = "none";
+ ment.mnt_fsname = share_name ? share_name : "none";
ment.mnt_dir = fullpath(mount_point);
ment.mnt_type = "smbfs";
ment.mnt_opts = "";
\
 
 \ /
  Last update: 2005-03-22 13:41    [W:0.033 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site