summaryrefslogtreecommitdiff
path: root/source3/client/umount.cifs.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2008-11-06 15:07:07 -0500
committerJeff Layton <jlayton@redhat.com>2008-11-06 15:07:07 -0500
commit32695912dd3ed7c02da68209328d630c89d395ba (patch)
tree9fe8734a10f5a2a79980dff0578db12de0288530 /source3/client/umount.cifs.c
parentdb26f7b7c49b6d4254ce5da7097e062b7dbd0409 (diff)
downloadsamba-32695912dd3ed7c02da68209328d630c89d395ba.tar.gz
samba-32695912dd3ed7c02da68209328d630c89d395ba.tar.bz2
samba-32695912dd3ed7c02da68209328d630c89d395ba.zip
mount.cifs: use lock/unlock_mtab scheme from util-linux-ng mount prog
The util-linux-ng sources have a good, but rather complex scheme for locking the mtab before updating it. Mount helpers need to follow the same scheme. Advisory locking only works if everyone is using the same locking scheme. Copy the routines we need from util-linux-ng into a separate source file and then have mount.cifs and umount.cifs link in this object. The long term goal is to have these routines in a separate helper library (libmount). Mount helpers can then dynamically link in that lib. Until that happens, this should serve as a suitable stopgap solution. Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'source3/client/umount.cifs.c')
-rw-r--r--source3/client/umount.cifs.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/source3/client/umount.cifs.c b/source3/client/umount.cifs.c
index 3e2415ad00..aff7cea397 100644
--- a/source3/client/umount.cifs.c
+++ b/source3/client/umount.cifs.c
@@ -33,9 +33,10 @@
#include <errno.h>
#include <string.h>
#include <mntent.h>
+#include "mount.h"
#define UNMOUNT_CIFS_VERSION_MAJOR "0"
-#define UNMOUNT_CIFS_VERSION_MINOR "5"
+#define UNMOUNT_CIFS_VERSION_MINOR "6"
#ifndef UNMOUNT_CIFS_VENDOR_SUFFIX
#ifdef _SAMBA_BUILD_
@@ -137,24 +138,6 @@ static int umount_check_perm(char * dir)
return rc;
}
-static int lock_mtab(void)
-{
- int rc;
-
- rc = mknod(MOUNTED_LOCK , 0600, 0);
- if(rc == -1)
- printf("\ngetting lock file %s failed with %s\n",MOUNTED_LOCK,
- strerror(errno));
-
- return rc;
-
-}
-
-static void unlock_mtab(void)
-{
- unlink(MOUNTED_LOCK);
-}
-
static int remove_from_mtab(char * mountpoint)
{
int rc;
@@ -168,6 +151,7 @@ static int remove_from_mtab(char * mountpoint)
/* Do we first need to check if it is writable? */
+ atexit(unlock_mtab);
if (lock_mtab()) {
printf("Mount table locked\n");
return -EACCES;