rpms/autofs/devel autofs-5.0.1-rc2-dont-create-remote-dirs.patch, NONE, 1.1 autofs.spec, 1.157, 1.158

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Wed Oct 25 08:56:32 UTC 2006


Author: ikent

Update of /cvs/dist/rpms/autofs/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv26391

Modified Files:
	autofs.spec 
Added Files:
	autofs-5.0.1-rc2-dont-create-remote-dirs.patch 
Log Message:
* Wed Oct 25 2006 Ian Kent <ikent at redhat.com> - 5.0.1-0.rc2.18
- deal with changed semantics of mkdir in recent kernels.


autofs-5.0.1-rc2-dont-create-remote-dirs.patch:
 CHANGELOG           |    1 
 daemon/automount.c  |   42 +++++++++++++++++++++++----------
 daemon/indirect.c   |    2 -
 include/automount.h |    2 +
 lib/mounts.c        |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 98 insertions(+), 14 deletions(-)

--- NEW FILE autofs-5.0.1-rc2-dont-create-remote-dirs.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index 6007086..04d8159 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -26,6 +26,7 @@
 - fix get_query_dn not looking in subtree for LDAP search (missed second
   occurance).
 - allow additional common LDAP attributes in map dn.
+- deal with changed semantics of mkdir in 2.6.19.
 
 1/9/2006 autofs-5.0.1 rc2
 -------------------------
diff --git a/daemon/automount.c b/daemon/automount.c
index 343fd68..3220ba0 100644
--- a/daemon/automount.c
+++ b/daemon/automount.c
@@ -72,6 +72,32 @@ static int umount_all(struct autofs_poin
 extern pthread_mutex_t master_mutex;
 extern struct master *master_list;
 
+static int do_mkdir(const char *path, mode_t mode)
+{
+	int status;
+	struct stat st;
+
+	status = stat(path, &st);
+	if (status == 0) {
+		if (!S_ISDIR(st.st_mode)) {
+			errno = ENOTDIR;
+			return 0;
+		}
+		return 1;
+	}
+
+	if (contained_in_local_fs(path)) {
+		if (mkdir(path, mode) == -1) {
+			if (errno == EEXIST)
+				return 1;
+			return 0;
+		}
+		return 1;
+	}
+
+	return 0;
+}
+
 int mkdir_path(const char *path, mode_t mode)
 {
 	char *buf = alloca(strlen(path) + 1);
@@ -84,19 +110,9 @@ int mkdir_path(const char *path, mode_t 
 			bp += cp - lcp;
 			lcp = cp;
 			*bp = '\0';
-			if (mkdir(buf, mode) == -1) {
-				/* If it already exists, make sure it's a directory */
-				if (errno == EEXIST) {
-					struct stat st;
-
-					if (stat(buf, &st) == 0 && !S_ISDIR(st.st_mode))
-						errno = ENOTDIR;
-					else {
-						/* last component, return -1 */
-						if (*cp != '\0')
-							continue;
-					}
-				}
+			if (!do_mkdir(buf, mode)) {
+				if (*cp != '\0')
+					continue;
 				return -1;
 			}
 		}
diff --git a/daemon/indirect.c b/daemon/indirect.c
index 608f37b..492cbbb 100644
--- a/daemon/indirect.c
+++ b/daemon/indirect.c
@@ -171,7 +171,7 @@ static int do_mount_autofs_indirect(stru
 	if (mkdir_path(ap->path, 0555) < 0) {
 		if (errno != EEXIST && errno != EROFS) {
 			crit(ap->logopt,
-			     "failed to create iautofs directory %s",
+			     "failed to create autofs directory %s",
 			     ap->path);
 			goto out_err;
 		}
diff --git a/include/automount.h b/include/automount.h
index 9c2de00..798cc50 100644
--- a/include/automount.h
+++ b/include/automount.h
@@ -322,6 +322,7 @@ #define MNTS_AUTOFS	0x0004
 
 struct mnt_list {
 	char *path;
+	char *fs_name;
 	char *fs_type;
 	char *opts;
 	pid_t owner;
@@ -350,6 +351,7 @@ char *make_mnt_name_string(char *path);
 struct mnt_list *get_mnt_list(const char *table, const char *path, int include);
 struct mnt_list *reverse_mnt_list(struct mnt_list *list);
 void free_mnt_list(struct mnt_list *list);
+int contained_in_local_fs(const char *path);
 int is_mounted(const char *table, const char *path, unsigned int type);
 int has_fstab_option(const char *opt);
 char *find_mnt_ino(const char *table, dev_t dev, ino_t ino);
diff --git a/lib/mounts.c b/lib/mounts.c
index 46131cd..008f92a 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -19,6 +19,7 @@ #include <mntent.h>
 #include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/vfs.h>
 #include <stdio.h>
 
 #include "automount.h"
@@ -170,6 +171,14 @@ struct mnt_list *get_mnt_list(const char
 		}
 		strcpy(ent->path, mnt->mnt_dir);
 
+		ent->fs_name = malloc(strlen(mnt->mnt_fsname) + 1);
+		if (!ent->fs_name) {
+			endmntent(tab);
+			free_mnt_list(list);
+			return NULL;
+		}
+		strcpy(ent->fs_name, mnt->mnt_fsname);
+
 		ent->fs_type = malloc(strlen(mnt->mnt_type) + 1);
 		if (!ent->fs_type) {
 			free(ent->path);
@@ -240,6 +249,9 @@ void free_mnt_list(struct mnt_list *list
 		if (this->path)
 			free(this->path);
 
+		if (this->fs_name)
+			free(this->fs_name);
+
 		if (this->fs_type)
 			free(this->fs_type);
 
@@ -250,6 +262,47 @@ void free_mnt_list(struct mnt_list *list
 	}
 }
 
+int contained_in_local_fs(const char *path)
+{
+	struct mnt_list *mnts, *this;
+	size_t pathlen = strlen(path);
+	struct statfs fs;
+	int rv, ret;
+
+	if (!path || !pathlen || pathlen > PATH_MAX)
+		return 0;
+
+	mnts = get_mnt_list(_PATH_MOUNTED, "/", 1);
+	if (!mnts)
+		return 0;
+
+	ret = 0;
+
+	for (this = mnts; this != NULL; this = this->next) {
+		size_t len = strlen(this->path);
+
+		if (!strncmp(path, this->path, len)) {
+			if (len > 1 && pathlen > len && path[len] != '/')
+				continue;
+			rv = statfs(this->path, &fs);
+			if (rv != -1 && fs.f_type == AUTOFS_SUPER_MAGIC)
+				ret = 1;
+			else if (this->fs_name[0] == '/') {
+				if (strlen(this->fs_name) > 1) {
+					if (this->fs_name[1] != '/')
+						ret = 1;
+				} else
+					ret = 1;
+			}
+			break;
+		}
+	}
+
+	free_mnt_list(mnts);
+
+	return ret;
+}
+
 int is_mounted(const char *table, const char *path, unsigned int type)
 {
 	struct mntent *mnt;
@@ -497,6 +550,7 @@ void tree_free_mnt_tree(struct mnt_list 
 		list_del(&this->self);
 
 		free(this->path);
+		free(this->fs_name);
 		free(this->fs_type);
 
 		if (this->opts)
@@ -570,8 +624,18 @@ struct mnt_list *tree_make_mnt_tree(cons
 		}
 		strcpy(ent->path, mnt->mnt_dir);
 
+		ent->fs_name = malloc(strlen(mnt->mnt_fsname) + 1);
+		if (!ent->fs_name) {
+			free(ent->path);
+			endmntent(tab);
+			tree_free_mnt_tree(tree);
+			return NULL;
+		}
+		strcpy(ent->fs_name, mnt->mnt_fsname);
+
 		ent->fs_type = malloc(strlen(mnt->mnt_type) + 1);
 		if (!ent->fs_type) {
+			free(ent->fs_name);
 			free(ent->path);
 			endmntent(tab);
 			tree_free_mnt_tree(tree);
@@ -582,6 +646,7 @@ struct mnt_list *tree_make_mnt_tree(cons
 		ent->opts = malloc(strlen(mnt->mnt_opts) + 1);
 		if (!ent->opts) {
 			free(ent->fs_type);
+			free(ent->fs_name);
 			free(ent->path);
 			endmntent(tab);
 			tree_free_mnt_tree(tree);


Index: autofs.spec
===================================================================
RCS file: /cvs/dist/rpms/autofs/devel/autofs.spec,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -r1.157 -r1.158
--- autofs.spec	20 Oct 2006 02:03:45 -0000	1.157
+++ autofs.spec	25 Oct 2006 08:56:30 -0000	1.158
@@ -4,7 +4,7 @@
 Summary: A tool for automatically mounting and unmounting filesystems.
 Name: autofs
 %define version 5.0.1
-%define release 0.rc2.16
+%define release 0.rc2.18
 Version: %{version}
 Release: %{release}
 Epoch: 1
@@ -34,6 +34,7 @@
 Patch20: autofs-5.0.1-rc2-numeric-ldap-host-name.patch
 Patch21: autofs-5.0.1-rc2-get_query_dn-subtree-2.patch
 Patch22: autofs-5.0.1-rc2-ldap-allow-extra-attrs.patch
+Patch23: autofs-5.0.1-rc2-dont-create-remote-dirs.patch
 Buildroot: /var/tmp/autofs-tmp
 BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel
 Prereq: chkconfig
@@ -96,6 +97,7 @@
 %patch20 -p1
 %patch21 -p1
 %patch22 -p1
+%patch23 -p1
 
 %build
 #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir}
@@ -152,6 +154,9 @@
 %{_libdir}/autofs/*
 
 %changelog
+* Wed Oct 25 2006 Ian Kent <ikent at redhat.com> - 5.0.1-0.rc2.18
+- deal with changed semantics of mkdir in recent kernels.
+
 * Fri Oct 20 2006 Ian Kent <ikent at redhat.com> - 5.0.1-0.rc2.16
 - fix get_query_dn not looking in subtree for LDAP search (missed
   econd occurance).




More information about the fedora-cvs-commits mailing list