1 diff --git a/CHANGELOG b/CHANGELOG
2 index 8df22ae..2ce58b4 100644
6 - add multi nsswitch lookup.
7 - change random multiple server selection option name to be consistent
8 with existing downstream version 4 naming.
9 +- fix mount point directory creation for bind mounts.
11 18/06/2007 autofs-5.0.2
12 -----------------------
13 diff --git a/daemon/automount.c b/daemon/automount.c
14 index 294c511..9809b9c 100644
15 --- a/daemon/automount.c
16 +++ b/daemon/automount.c
17 @@ -104,11 +104,14 @@ static int do_mkdir(const char *parent, const char *path, mode_t mode)
18 status = statfs(parent, &fs);
19 if ((status != -1 && fs.f_type == (__SWORD_TYPE) AUTOFS_SUPER_MAGIC) ||
20 contained_in_local_fs(path)) {
21 - if (mkdir(path, mode) == -1)
22 + if (mkdir(path, mode) == -1) {
33 diff --git a/daemon/direct.c b/daemon/direct.c
34 index 179e74b..9a39a6f 100644
37 @@ -604,6 +604,14 @@ int umount_autofs_offset(struct autofs_point *ap, struct mapent *me)
39 ioctlfd = me->ioctlfd;
41 + /* offset isn't mounted, return success and try to recover */
42 + if (!is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) {
44 + "offset %s unexpectedly not mounted",
49 ioctlfd = open(me->key, O_RDONLY);
51 if ((cl_flags = fcntl(ioctlfd, F_GETFD, 0)) != -1) {
52 @@ -689,11 +697,19 @@ force_umount:
54 msg("umounted offset mount %s", me->key);
56 + if (!rv && me->dir_created) {
57 + if (rmdir(me->key) == -1) {
58 + char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
59 + warn(ap->logopt, "failed to remove dir %s: %s",
66 -int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autofs_fs)
67 +int mount_autofs_offset(struct autofs_point *ap, struct mapent *me)
69 + char buf[MAX_ERR_BUF];
70 struct mnt_params *mp;
71 time_t timeout = ap->exp_timeout;
73 @@ -740,36 +756,38 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autof
78 - /* In case the directory doesn't exist, try to mkdir it */
79 - if (mkdir_path(me->key, 0555) < 0) {
80 - if (errno != EEXIST) {
82 - "failed to create mount directory %s %d",
86 + /* In case the directory doesn't exist, try to mkdir it */
87 + if (mkdir_path(me->key, 0555) < 0) {
88 + if (errno == EEXIST) {
90 * If we recieve an error, and it's EEXIST
91 * we know the directory was not created.
94 + } else if (errno == EACCES) {
96 + * We require the mount point directory to exist when
97 + * installing multi-mount triggers into a host
100 + * If it doesn't exist it is not a valid part of the
103 + char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
105 + "can't create mount directory: %s, %s",
109 - /* No errors so the directory was successfully created */
110 - me->dir_created = 1;
111 + char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
113 + "failed to create mount directory: %s, %s",
118 - me->dir_created = 0;
121 - * We require the mount point directory to exist when
122 - * installing multi-mount triggers into a host filesystem.
124 - * If it doesn't exist it is not a valid part of the
125 - * mount heirachy so we silently succeed here.
127 - if (stat(me->key, &st) == -1 && errno == ENOENT)
129 + /* No errors so the directory was successfully created */
130 + me->dir_created = 1;
134 @@ -832,10 +850,8 @@ out_close:
138 - if (is_autofs_fs) {
139 - if (stat(me->key, &st) == 0 && me->dir_created)
140 - rmdir_path(ap, me->key, st.st_dev);
142 + if (stat(me->key, &st) == 0 && me->dir_created)
143 + rmdir_path(ap, me->key, st.st_dev);
147 diff --git a/include/automount.h b/include/automount.h
148 index 106ed0a..d9e4ecd 100644
149 --- a/include/automount.h
150 +++ b/include/automount.h
151 @@ -470,7 +470,7 @@ void *expire_proc_direct(void *);
152 int expire_offsets_direct(struct autofs_point *ap, struct mapent *me, int now);
153 int mount_autofs_indirect(struct autofs_point *ap);
154 int mount_autofs_direct(struct autofs_point *ap);
155 -int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autofs_fs);
156 +int mount_autofs_offset(struct autofs_point *ap, struct mapent *me);
157 void submount_signal_parent(struct autofs_point *ap, unsigned int success);
158 int umount_autofs(struct autofs_point *ap, int force);
159 int umount_autofs_indirect(struct autofs_point *ap);
160 diff --git a/lib/parse_subs.c b/lib/parse_subs.c
161 index 0c45905..ad19f34 100644
162 --- a/lib/parse_subs.c
163 +++ b/lib/parse_subs.c
164 @@ -388,10 +388,8 @@ int mount_multi_triggers(struct autofs_point *ap, char *root, struct mapent *me,
166 struct list_head *pos = NULL;
167 unsigned int fs_path_len;
170 - unsigned int mounted, is_autofs_fs;
172 + unsigned int mounted;
175 fs_path_len = strlen(root) + strlen(base);
176 if (fs_path_len > PATH_MAX)
177 @@ -399,15 +397,6 @@ int mount_multi_triggers(struct autofs_point *ap, char *root, struct mapent *me,
181 - ret = statfs(path, &fs);
183 - /* There's no mount yet - it must be autofs */
184 - if (errno == ENOENT)
189 - is_autofs_fs = fs.f_type == (__SWORD_TYPE) AUTOFS_SUPER_MAGIC ? 1 : 0;
192 start = strlen(root);
193 @@ -424,20 +413,9 @@ int mount_multi_triggers(struct autofs_point *ap, char *root, struct mapent *me,
198 - * If the host filesystem is not an autofs fs
199 - * we require the mount point directory exist
200 - * and that permissions are OK.
202 - if (!is_autofs_fs) {
203 - ret = stat(oe->key, &st);
208 debug(ap->logopt, "mount offset %s", oe->key);
210 - if (mount_autofs_offset(ap, oe, is_autofs_fs) < 0)
211 + if (mount_autofs_offset(ap, oe) < 0)
212 warn(ap->logopt, "failed to mount offset");