return errno;
file_dev = 0;
#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
- if (stat(file, &st_buf) == 0)
+ if ((stat(file, &st_buf) == 0) &&
+ S_ISBLK(st_buf.st_mode))
file_dev = st_buf.st_rdev;
-#endif
+#endif /* __GNU__ */
while ((mnt = getmntent (f)) != NULL) {
if (strcmp(file, mnt->mnt_fsname) == 0)
break;
#ifndef __GNU__
if (file_dev && (stat(mnt->mnt_fsname, &st_buf) == 0) &&
- file_dev == st_buf.st_rdev)
+ S_ISBLK(st_buf.st_mode) &&
+ (file_dev == st_buf.st_rdev))
break;
-#endif
+#endif /* __GNU__ */
}
if (mnt == 0) {
goto is_root;
}
}
-#endif
+#endif /* __GNU__ */
goto exit;
}
#ifndef __GNU__ /* The GNU hurd is deficient; what else is new? */
#ifdef DEBUG
printf("Bogus entry in %s! (%s does not exist)\n",
mtab_file, mnt->mnt_dir);
-#endif
+#endif /* DEBUG */
retval = 0;
}
goto exit;
#ifdef DEBUG
printf("Bogus entry in %s! (%s not mounted on %s)\n",
mtab_file, file, mnt->mnt_dir);
-#endif
+#endif /* DEBUG */
goto exit;
}
-#endif
+#endif /* __GNU__ */
*mount_flags = EXT2_MF_MOUNTED;
/* Check to see if the ro option is set */
return retval;
}
-/*
- * Check to see if we're dealing with the swap device.
- */
-static int is_swap_device(const char *file)
-{
- FILE *f;
- char buf[1024], *cp;
- dev_t file_dev;
- struct stat st_buf;
- int ret = 0;
-
- file_dev = 0;
-#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
- if (stat(file, &st_buf) == 0)
- file_dev = st_buf.st_rdev;
-#endif
-
- if (!(f = fopen("/proc/swaps", "r")))
- return 0;
- /* Skip the first line */
- fgets(buf, sizeof(buf), f);
- while (!feof(f)) {
- if (!fgets(buf, sizeof(buf), f))
- break;
- if ((cp = strchr(buf, ' ')) != NULL)
- *cp = 0;
- if ((cp = strchr(buf, '\t')) != NULL)
- *cp = 0;
- if (strcmp(buf, file) == 0) {
- ret++;
- break;
- }
-#ifndef __GNU__
- if (file_dev && (stat(buf, &st_buf) == 0) &&
- file_dev == st_buf.st_rdev) {
- ret++;
- break;
- }
-#endif
- }
- fclose(f);
- return ret;
-}
-
static errcode_t check_mntent(const char *file, int *mount_flags,
char *mtpt, int mtlen)
{
mtpt, mtlen);
if (retval == 0)
return 0;
-#endif
+#endif /* DEBUG */
#ifdef __linux__
retval = check_mntent_file("/proc/mounts", file, mount_flags,
mtpt, mtlen);
if (retval == 0)
return 0;
-#endif
+#endif /* __linux__ */
retval = check_mntent_file(MOUNTED, file, mount_flags, mtpt, mtlen);
return retval;
}
#endif /* HAVE_GETMNTINFO */
/*
+ * Check to see if we're dealing with the swap device.
+ */
+static int is_swap_device(const char *file)
+{
+ FILE *f;
+ char buf[1024], *cp;
+ dev_t file_dev;
+ struct stat st_buf;
+ int ret = 0;
+
+ file_dev = 0;
+#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
+ if ((stat(file, &st_buf) == 0) &&
+ S_ISBLK(st_buf.st_mode))
+ file_dev = st_buf.st_rdev;
+#endif /* __GNU__ */
+
+ if (!(f = fopen("/proc/swaps", "r")))
+ return 0;
+ /* Skip the first line */
+ fgets(buf, sizeof(buf), f);
+ while (!feof(f)) {
+ if (!fgets(buf, sizeof(buf), f))
+ break;
+ if ((cp = strchr(buf, ' ')) != NULL)
+ *cp = 0;
+ if ((cp = strchr(buf, '\t')) != NULL)
+ *cp = 0;
+ if (strcmp(buf, file) == 0) {
+ ret++;
+ break;
+ }
+#ifndef __GNU__
+ if (file_dev && (stat(buf, &st_buf) == 0) &&
+ S_ISBLK(st_buf.st_mode) &&
+ file_dev == st_buf.st_rdev) {
+ ret++;
+ break;
+ }
+#endif /* __GNU__ */
+ }
+ fclose(f);
+ return ret;
+}
+
+
+/*
* ext2fs_check_mount_point() returns 1 if the device is mounted, 0
* otherwise. If mtpt is non-NULL, the directory where the device is
* mounted is copied to where mtpt is pointing, up to mtlen
exit(0);
}
-#endif
+#endif /* DEBUG */