path = strtok(search_path, ":");
while (path) {
+ int type_opt = 0;
+
res = snprintf(mountprog, sizeof(mountprog), "%s/mount.%s",
path, type);
path = strtok(NULL, ":");
if (res >= sizeof(mountprog) || res < 0)
continue;
- if (stat(mountprog, &statbuf))
+ res = stat(mountprog, &statbuf);
+ if (res == -1 && errno == ENOENT && strchr(type, '.')) {
+ /* If type ends with ".subtype" try without it */
+ *strrchr(mountprog, '.') = '\0';
+ type_opt = 1;
+ res = stat(mountprog, &statbuf);
+ }
+ if (res)
continue;
if (verbose)
switch (fork()) {
case 0: { /* child */
- char *oo, *mountargs[10];
+ char *oo, *mountargs[12];
int i = 0;
if (setgid(getgid()) < 0)
mountargs[i++] = "-o"; /* 8 */
mountargs[i++] = oo; /* 9 */
}
- mountargs[i] = NULL; /* 10 */
+ if (type_opt) {
+ mountargs[i++] = "-t"; /* 10 */
+ mountargs[i++] = (char *) type; /* 11 */
+ }
+ mountargs[i] = NULL; /* 12 */
if (verbose > 2) {
i = 0;
return 0;
if (strlen(type) < 100) {
+ int type_opt = 0;
+
sprintf(umountprog, "/sbin/umount.%s", type);
- if (stat(umountprog, &statbuf) == 0) {
+ res = stat(umountprog, &statbuf);
+ if (res == -1 && errno == ENOENT && strchr(type, '.')) {
+ /* If type ends with ".subtype" try without it */
+ *strrchr(umountprog, '.') = '\0';
+ type_opt = 1;
+ res = stat(umountprog, &statbuf);
+ }
+ if (res == 0) {
res = fork();
if (res == 0) {
- char *umountargs[8];
+ char *umountargs[10];
int i = 0;
if(setgid(getgid()) < 0)
umountargs[i++] = "-v";
if (remount)
umountargs[i++] = "-r";
+ if (type_opt) {
+ umountargs[i++] = "-t";
+ umountargs[i++] = (char *) type;
+ }
umountargs[i] = NULL;
execv(umountprog, umountargs);
exit(1); /* exec failed */