Re: autofs/smbfs - delayed mounting?

Urban Widmark (urban@svenskatest.se)
Mon, 30 Nov 1998 18:08:03 +0100 (MET)


On Mon, 30 Nov 1998, Michael H. Warfield wrote:

> Urban Widmark enscribed thusly:
>
> > This looks like a samba/smbfs problem, I'll report it to/fix it for them,
> > unless you or someone else already has. Thanks for pointing me in the
> > right direction.
>
> It is and I thought I had this fixed just prior to the 2.0b1
> release... Anything prior to that release will be busted with the
> timing error.

That would be this comment:
/*
* Create the background process after trying the mount.
* to avoid race conditions with automount and other processes.
*/
(about moving the daemonize() call after system(mount), change since 1.9?)

> Make sure that when you configure the samba package that you
> include the --with-smbmount option or smbmount, smbmnt, and smbumount
> will NOT get rebuilt and you may be left with some older version. To
> make sure, compare the date/times of your smbmount/smbumount binaries with
> the date on smbd/nmbd.
>

No I don't think there is any version confusion, and I'm sure I did
./configure --with-smbmount

cola:/usr/local/samba/bin#d smbd* nmbd* smbmnt* smbmount*
-rwxr-xr-x 1 root root 412032 Nov 30 10:15 nmbd*
-rwxr-xr-x 1 root root 412032 Nov 24 16:30 nmbd.old*
-rwxr-xr-x 1 root root 768176 Nov 30 10:15 smbd*
-rwxr-xr-x 1 root root 768176 Nov 24 16:30 smbd.old*
-rwxr-xr-x 1 root root 261457 Nov 30 10:15 smbmnt*
-rwxr-xr-x 1 root root 261457 Nov 24 16:30 smbmnt.old*
-rwxr-xr-x 1 root root 291145 Nov 30 10:15 smbmount*
-rwxr-xr-x 1 root root 290689 Nov 24 16:30 smbmount.old*

(new smbmount is with the included patch applied)

send_fs_socket() contains:
res = ioctl(fd, SMB_IOC_NEWCONN, &conn_options);
and my question is if the mountpoint is valid before this call or not.

My patch makes sure that the parent stays alive until after this call. The
#includes should be moved to a better place, and then sync can probably be
done in some much nicer way.

But it has removed the problem for me (with less than one day of
testing).

I sent this to the samba team (PR#11592), but I guess that was the wrong
place after all?

/Urban

---
Urban Widmark                           urban@svenskatest.se
Svenska Test AB                         +46 90 71 71 23

--- smbmount.c.org Mon Nov 30 10:01:26 1998 +++ smbmount.c Mon Nov 30 10:05:42 1998 @@ -137,6 +137,48 @@ #define CNV_LANG(s) dos_to_unix(s,False) #define CNV_INPUT(s) unix_to_dos(s,True) + +/**************************************************************************** +synchronization of parent and child +****************************************************************************/ +#include <stdlib.h> +#include <unistd.h> +#include <signal.h> +#include <stdio.h> + +static volatile sig_atomic_t sigflag; + +static void sigusr1_handler() +{ + sigflag = 1; +} + +int wait_for_child() +{ + sigset_t zeromask; + struct sigaction sa; + + sigemptyset(&zeromask); + + sa.sa_handler = sigusr1_handler; + sa.sa_flags = SA_ONESHOT; + sigemptyset(&sa.sa_mask); + if(sigaction(SIGUSR1, &sa, NULL) == -1) + return -1; + + while(sigflag == 0) + sigsuspend(&zeromask); + sigflag = 0; + + return 0; +} + +void wakeup_parent(pid_t pid) +{ + kill(pid, SIGUSR1); +} + + /**************************************************************************** check for existance of a dir ****************************************************************************/ @@ -191,7 +233,8 @@ } if (i > 0) { - /* parent simply exits */ + /* when the child has mounted the fs, the parent simply exits */ + wait_for_child(); exit(0); } setsid(); @@ -255,6 +298,7 @@ send_fs_socket(char *mount_point, char *inbuf, char *outbuf) { int fd, closed = 0, res = 1; + int has_parent = 1; while (1) { @@ -289,6 +333,11 @@ close_our_files(); } #endif + + if(has_parent) { + wakeup_parent(getppid()); + has_parent = 0; + } /* * Wait for a signal from smbfs ...

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/