On Mon, 28 Jun 2004, Phy Prabab wrote:
> Ian,
>
> Of course I am willing to test out patches. Please
> post location and I can try to test it out
> tonight/tomrrow morning US time.
Cool.
Attached is the patch that may help with the problem you describe.
I recommend that you first also apply the patches:
autofs-4.1.3-strict.patch
autofs-4.1.3-mtab_lock.patch
located at http://www.kernel.org/pub/linux/daemons/autofs/v4.
Ian
diff -Nur autofs-4.1.3.orig/daemon/automount.c autofs-4.1.3/daemon/automount.c
--- autofs-4.1.3.orig/daemon/automount.c 2004-04-05 21:14:10.000000000 +0800
+++ autofs-4.1.3/daemon/automount.c 2004-06-05 21:13:28.000000000 +0800
@@ -99,8 +99,11 @@
if (stat(buf, &st) == 0 &&
!S_ISDIR(st.st_mode))
errno = ENOTDIR;
- else
- continue;
+ else {
+ /* last component, return -1 */
+ if (*cp != '\0')
+ continue;
+ }
}
return -1;
}
@@ -1088,9 +1091,11 @@
close(ap.state_pipe[0]);
close(ap.state_pipe[1]);
+ chdir(ap.path);
err = ap.lookup->lookup_mount(ap.path,
pkt->name, pkt->len,
ap.lookup->context);
+ chdir("/");
/*
* If at first you don't succeed, hide all
@@ -1163,8 +1168,11 @@
it.
*/
+ chdir(ap.path);
ret = ap.lookup->lookup_mount(ap.path,
name, namelen, ap.lookup->context);
+ chdir("/");
+
if (ret)
error("failed to recover from partial expiry of %s\n",
buf);
diff -Nur autofs-4.1.3.orig/modules/mount_bind.c autofs-4.1.3/modules/mount_bind.c
--- autofs-4.1.3.orig/modules/mount_bind.c 2004-05-10 20:44:30.000000000 +0800
+++ autofs-4.1.3/modules/mount_bind.c 2004-06-05 18:12:38.000000000 +0800
@@ -107,15 +107,19 @@
fullpath[i] = '\0';
if (bind_works) {
- int status;
+ int status, existed = 1;
debug(MODPREFIX "calling mkdir_path %s", fullpath);
- if ((status = mkdir_path(fullpath, 0555)) && errno != EEXIST) {
+ status = mkdir_path(fullpath, 0555);
+ if (status && errno != EEXIST) {
error(MODPREFIX "mkdir_path %s failed: %m", fullpath);
return 1;
}
+ if (!status)
+ existed = 0;
+
if (is_mounted(fullpath)) {
warn("BUG: %s already mounted", fullpath);
return 0;
@@ -130,7 +134,7 @@
unlink(AUTOFS_LOCK);
if (err) {
- if (!ap.ghost && name_len)
+ if ((!ap.ghost && name_len) || !existed)
rmdir_path(name);
return 1;
} else {
diff -Nur autofs-4.1.3.orig/modules/mount_changer.c
autofs-4.1.3/modules/mount_changer.c
--- autofs-4.1.3.orig/modules/mount_changer.c 2004-05-10 20:44:30.000000000 +0800
+++ autofs-4.1.3/modules/mount_changer.c 2004-06-05 18:18:04.000000000 +0800
@@ -52,7 +52,7 @@
{
char *fullpath;
int err;
- int status;
+ int status, existed = 1;
fstype = "iso9660";
@@ -80,11 +80,15 @@
debug(MODPREFIX "calling mkdir_path %s", fullpath);
- if ((status = mkdir_path(fullpath, 0555)) && errno != EEXIST) {
+ status = mkdir_path(fullpath, 0555);
+ if (status && errno != EEXIST) {
error(MODPREFIX "mkdir_path %s failed: %m", fullpath);
return 1;
}
+ if (!status)
+ existed = 0;
+
debug(MODPREFIX "Swapping CD to slot %s", name);
err = swapCD(what, name);
@@ -111,7 +115,7 @@
unlink(AUTOFS_LOCK);
if (err) {
- if (!ap.ghost && name_len)
+ if ((!ap.ghost && name_len) || !existed)
rmdir_path(name);
error(MODPREFIX "failed to mount %s (type %s) on %s",
diff -Nur autofs-4.1.3.orig/modules/mount_ext2.c autofs-4.1.3/modules/mount_ext2.c
--- autofs-4.1.3.orig/modules/mount_ext2.c 2004-05-10 20:44:30.000000000 +0800
+++ autofs-4.1.3/modules/mount_ext2.c 2004-06-05 18:23:09.000000000 +0800
@@ -40,7 +40,6 @@
return 0;
}
-
int mount_mount(const char *root, const char *name, int name_len,
const char *what, const char *fstype, const char *options, void
*context)
{
@@ -48,7 +47,7 @@
const char *p, *p1;
int err, ro = 0;
const char *fsck_prog;
- int status;
+ int status, existed = 1;
fullpath = alloca(strlen(root) + name_len + 2);
if (!fullpath) {
@@ -63,11 +62,15 @@
debug(MODPREFIX "calling mkdir_path %s", fullpath);
- if ((status = mkdir_path(fullpath, 0555)) && errno != EEXIST) {
+ status = mkdir_path(fullpath, 0555);
+ if (status && errno != EEXIST) {
error(MODPREFIX "mkdir_path %s failed: %m", fullpath);
return 1;
}
+ if (!status)
+ existed = 0;
+
if (is_mounted(fullpath)) {
error("BUG: %s already mounted", fullpath);
return 0;
@@ -120,7 +123,7 @@
unlink(AUTOFS_LOCK);
if (err) {
- if (!ap.ghost && name_len)
+ if ((!ap.ghost && name_len) || !existed)
rmdir_path(name);
error(MODPREFIX "failed to mount %s (type %s) on %s",
what, fstype, fullpath);
diff -Nur autofs-4.1.3.orig/modules/mount_generic.c
autofs-4.1.3/modules/mount_generic.c
--- autofs-4.1.3.orig/modules/mount_generic.c 2004-05-10 20:44:30.000000000 +0800
+++ autofs-4.1.3/modules/mount_generic.c 2004-06-05 18:22:10.000000000 +0800
@@ -46,7 +46,7 @@
{
char *fullpath;
int err;
- int status;
+ int status, existed = 1;
fullpath = alloca(strlen(root) + name_len + 2);
if (!fullpath) {
@@ -61,11 +61,15 @@
debug(MODPREFIX "calling mkdir_path %s", fullpath);
- if ((status = mkdir_path(fullpath, 0555)) && errno != EEXIST) {
+ status = mkdir_path(fullpath, 0555);
+ if (status && errno != EEXIST) {
error(MODPREFIX "mkdir_path %s failed: %m", fullpath);
return 1;
}
+ if (!status)
+ existed = 0;
+
if (is_mounted(fullpath)) {
error("BUG: %s already mounted", fullpath);
return 0;
@@ -89,7 +93,7 @@
unlink(AUTOFS_LOCK);
if (err) {
- if (!ap.ghost && name_len)
+ if ((!ap.ghost && name_len) || !existed)
rmdir_path(name);
error(MODPREFIX "failed to mount %s (type %s) on %s",
diff -Nur autofs-4.1.3.orig/modules/mount_nfs.c autofs-4.1.3/modules/mount_nfs.c
--- autofs-4.1.3.orig/modules/mount_nfs.c 2004-06-05 14:24:58.000000000 +0800
+++ autofs-4.1.3/modules/mount_nfs.c 2004-06-05 21:10:17.000000000 +0800
@@ -445,14 +445,19 @@
whatstr, "bind", NULL, mount_bind->context);
} else {
/* Not a local host - do an NFS mount */
- int status;
+ int status, existed = 1;
debug(MODPREFIX "calling mkdir_path %s", fullpath);
- if ((status = mkdir_path(fullpath, 0555)) && errno != EEXIST) {
+
+ status = mkdir_path(fullpath, 0555);
+ if (status && errno != EEXIST) {
error(MODPREFIX "mkdir_path %s failed: %m", fullpath);
return 1;
}
+ if (!status)
+ existed = 0;
+
if (is_mounted(fullpath)) {
error("BUG: %s already mounted", fullpath);
return 0;
@@ -477,8 +482,9 @@
unlink(AUTOFS_LOCK);
if (err) {
- if (!ap.ghost && name_len)
+ if ((!ap.ghost && name_len) || !existed)
rmdir_path(name);
+
error(MODPREFIX "nfs: mount failure %s on %s",
whatstr, fullpath);
return 1;
_______________________________________________
autofs mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/autofs