blob: 2c1bd752b3c13b59f541388b317e57284c4d14f9 [file] [log] [blame]
Theodore Ts'o50e1e101997-04-26 13:58:21 +00001/*
Theodore Ts'o19c78dc1997-04-29 16:17:09 +00002 * ismounted.c --- Check to see if the filesystem was mounted
Theodore Ts'oefc6f622008-08-27 23:07:54 -04003 *
Theodore Ts'occ860172001-05-25 16:32:53 +00004 * Copyright (C) 1995,1996,1997,1998,1999,2000 Theodore Ts'o.
Theodore Ts'o19c78dc1997-04-29 16:17:09 +00005 *
6 * %Begin-Header%
Theodore Ts'o543547a2010-05-17 21:31:56 -04007 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
Theodore Ts'o19c78dc1997-04-29 16:17:09 +00009 * %End-Header%
Theodore Ts'o50e1e101997-04-26 13:58:21 +000010 */
11
Theodore Ts'od1154eb2011-09-18 17:34:37 -040012#include "config.h"
Theodore Ts'o50e1e101997-04-26 13:58:21 +000013#include <stdio.h>
14#if HAVE_UNISTD_H
15#include <unistd.h>
16#endif
Theodore Ts'oc4e749a1998-02-20 05:33:14 +000017#if HAVE_ERRNO_H
18#include <errno.h>
19#endif
Theodore Ts'o50e1e101997-04-26 13:58:21 +000020#include <fcntl.h>
Theodore Ts'o50e1e101997-04-26 13:58:21 +000021#ifdef HAVE_LINUX_FD_H
22#include <linux/fd.h>
23#endif
24#ifdef HAVE_MNTENT_H
25#include <mntent.h>
26#endif
27#ifdef HAVE_GETMNTINFO
28#include <paths.h>
29#include <sys/param.h>
30#include <sys/mount.h>
31#endif /* HAVE_GETMNTINFO */
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000032#include <string.h>
Theodore Ts'occ860172001-05-25 16:32:53 +000033#include <sys/stat.h>
Theodore Ts'o50e1e101997-04-26 13:58:21 +000034
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +000035#include "ext2_fs.h"
Theodore Ts'o50e1e101997-04-26 13:58:21 +000036#include "ext2fs.h"
37
Theodore Ts'ob24efa22012-04-05 15:31:09 -070038#ifdef HAVE_SETMNTENT
Theodore Ts'o50e1e101997-04-26 13:58:21 +000039/*
Theodore Ts'o52db0b42001-04-17 02:22:05 +000040 * Helper function which checks a file in /etc/mtab format to see if a
41 * filesystem is mounted. Returns an error if the file doesn't exist
Theodore Ts'oefc6f622008-08-27 23:07:54 -040042 * or can't be opened.
Theodore Ts'o50e1e101997-04-26 13:58:21 +000043 */
Theodore Ts'oefc6f622008-08-27 23:07:54 -040044static errcode_t check_mntent_file(const char *mtab_file, const char *file,
Theodore Ts'o52db0b42001-04-17 02:22:05 +000045 int *mount_flags, char *mtpt, int mtlen)
Theodore Ts'o50e1e101997-04-26 13:58:21 +000046{
Theodore Ts'o2038b632001-09-14 07:44:25 -040047 struct mntent *mnt;
Theodore Ts'oa8fd6e32001-12-24 01:40:35 -050048 struct stat st_buf;
Theodore Ts'o2038b632001-09-14 07:44:25 -040049 errcode_t retval = 0;
Theodore Ts'o3a42fe22002-10-31 13:23:37 -050050 dev_t file_dev=0, file_rdev=0;
51 ino_t file_ino=0;
Theodore Ts'o2038b632001-09-14 07:44:25 -040052 FILE *f;
53 int fd;
Theodore Ts'o50e1e101997-04-26 13:58:21 +000054
55 *mount_flags = 0;
Theodore Ts'o42b61c52013-07-08 12:08:44 -040056 if ((f = setmntent (mtab_file, "r")) == NULL) {
57 if (errno == ENOENT) {
58 if (getenv("EXT2FS_NO_MTAB_OK"))
59 return 0;
60 else
Zheng Liu8ab39552013-08-05 13:02:43 +080061 return EXT2_ET_NO_MTAB_FILE;
Theodore Ts'o42b61c52013-07-08 12:08:44 -040062 }
63 return errno;
64 }
Theodore Ts'o3a42fe22002-10-31 13:23:37 -050065 if (stat(file, &st_buf) == 0) {
66 if (S_ISBLK(st_buf.st_mode)) {
Theodore Ts'oa8fd6e32001-12-24 01:40:35 -050067#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
Theodore Ts'o3a42fe22002-10-31 13:23:37 -050068 file_rdev = st_buf.st_rdev;
Theodore Ts'of0efd292002-04-27 17:07:52 -040069#endif /* __GNU__ */
Theodore Ts'o3a42fe22002-10-31 13:23:37 -050070 } else {
71 file_dev = st_buf.st_dev;
72 file_ino = st_buf.st_ino;
73 }
74 }
Theodore Ts'oa8fd6e32001-12-24 01:40:35 -050075 while ((mnt = getmntent (f)) != NULL) {
Theodore Ts'of9110f42009-04-22 22:20:22 -040076 if (mnt->mnt_fsname[0] != '/')
77 continue;
Theodore Ts'o50e1e101997-04-26 13:58:21 +000078 if (strcmp(file, mnt->mnt_fsname) == 0)
79 break;
Theodore Ts'o3a42fe22002-10-31 13:23:37 -050080 if (stat(mnt->mnt_fsname, &st_buf) == 0) {
81 if (S_ISBLK(st_buf.st_mode)) {
Theodore Ts'oa8fd6e32001-12-24 01:40:35 -050082#ifndef __GNU__
Theodore Ts'o3a42fe22002-10-31 13:23:37 -050083 if (file_rdev && (file_rdev == st_buf.st_rdev))
84 break;
Theodore Ts'of0efd292002-04-27 17:07:52 -040085#endif /* __GNU__ */
Theodore Ts'o3a42fe22002-10-31 13:23:37 -050086 } else {
87 if (file_dev && ((file_dev == st_buf.st_dev) &&
88 (file_ino == st_buf.st_ino)))
89 break;
90 }
91 }
Theodore Ts'oa8fd6e32001-12-24 01:40:35 -050092 }
Theodore Ts'occ860172001-05-25 16:32:53 +000093
94 if (mnt == 0) {
Theodore Ts'o66a46142001-06-13 23:26:19 +000095#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
Theodore Ts'occ860172001-05-25 16:32:53 +000096 /*
97 * Do an extra check to see if this is the root device. We
Theodore Ts'o2038b632001-09-14 07:44:25 -040098 * can't trust /etc/mtab, and /proc/mounts will only list
Theodore Ts'occ860172001-05-25 16:32:53 +000099 * /dev/root for the root filesystem. Argh. Instead we
100 * check if the given device has the same major/minor number
101 * as the device that the root directory is on.
102 */
Theodore Ts'o3a42fe22002-10-31 13:23:37 -0500103 if (file_rdev && stat("/", &st_buf) == 0) {
104 if (st_buf.st_dev == file_rdev) {
Theodore Ts'occ860172001-05-25 16:32:53 +0000105 *mount_flags = EXT2_MF_MOUNTED;
106 if (mtpt)
Theodore Ts'od5f858d2001-05-25 17:14:23 +0000107 strncpy(mtpt, "/", mtlen);
Theodore Ts'occ860172001-05-25 16:32:53 +0000108 goto is_root;
109 }
110 }
Theodore Ts'of0efd292002-04-27 17:07:52 -0400111#endif /* __GNU__ */
Theodore Ts'o48e6e812003-07-06 00:36:48 -0400112 goto errout;
Theodore Ts'occ860172001-05-25 16:32:53 +0000113 }
Theodore Ts'o2038b632001-09-14 07:44:25 -0400114#ifndef __GNU__ /* The GNU hurd is deficient; what else is new? */
115 /* Validate the entry in case /etc/mtab is out of date */
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400116 /*
Theodore Ts'o2038b632001-09-14 07:44:25 -0400117 * We need to be paranoid, because some broken distributions
118 * (read: Slackware) don't initialize /etc/mtab before checking
119 * all of the non-root filesystems on the disk.
120 */
Theodore Ts'oa8fd6e32001-12-24 01:40:35 -0500121 if (stat(mnt->mnt_dir, &st_buf) < 0) {
Theodore Ts'o2038b632001-09-14 07:44:25 -0400122 retval = errno;
123 if (retval == ENOENT) {
124#ifdef DEBUG
125 printf("Bogus entry in %s! (%s does not exist)\n",
126 mtab_file, mnt->mnt_dir);
Theodore Ts'of0efd292002-04-27 17:07:52 -0400127#endif /* DEBUG */
Theodore Ts'o2038b632001-09-14 07:44:25 -0400128 retval = 0;
129 }
Theodore Ts'o48e6e812003-07-06 00:36:48 -0400130 goto errout;
Theodore Ts'o2038b632001-09-14 07:44:25 -0400131 }
Theodore Ts'o3a42fe22002-10-31 13:23:37 -0500132 if (file_rdev && (st_buf.st_dev != file_rdev)) {
Theodore Ts'o2038b632001-09-14 07:44:25 -0400133#ifdef DEBUG
Theodore Ts'oa8fd6e32001-12-24 01:40:35 -0500134 printf("Bogus entry in %s! (%s not mounted on %s)\n",
135 mtab_file, file, mnt->mnt_dir);
Theodore Ts'of0efd292002-04-27 17:07:52 -0400136#endif /* DEBUG */
Theodore Ts'o48e6e812003-07-06 00:36:48 -0400137 goto errout;
Theodore Ts'o2038b632001-09-14 07:44:25 -0400138 }
Theodore Ts'of0efd292002-04-27 17:07:52 -0400139#endif /* __GNU__ */
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000140 *mount_flags = EXT2_MF_MOUNTED;
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400141
Theodore Ts'offf45482003-04-13 00:44:19 -0400142#ifdef MNTOPT_RO
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000143 /* Check to see if the ro option is set */
144 if (hasmntopt(mnt, MNTOPT_RO))
145 *mount_flags |= EXT2_MF_READONLY;
Theodore Ts'offf45482003-04-13 00:44:19 -0400146#endif
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000147
Theodore Ts'occ860172001-05-25 16:32:53 +0000148 if (mtpt)
149 strncpy(mtpt, mnt->mnt_dir, mtlen);
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000150 /*
151 * Check to see if we're referring to the root filesystem.
152 * If so, do a manual check to see if we can open /etc/mtab
Theodore Ts'occ860172001-05-25 16:32:53 +0000153 * read/write, since if the root is mounted read/only, the
154 * contents of /etc/mtab may not be accurate.
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000155 */
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000156 if (!strcmp(mnt->mnt_dir, "/")) {
Theodore Ts'occ860172001-05-25 16:32:53 +0000157is_root:
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400158#define TEST_FILE "/.ismount-test-file"
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000159 *mount_flags |= EXT2_MF_ISROOT;
Andreas Dilger8cdd6a62007-11-08 18:20:15 -0700160 fd = open(TEST_FILE, O_RDWR|O_CREAT, 0600);
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000161 if (fd < 0) {
162 if (errno == EROFS)
163 *mount_flags |= EXT2_MF_READONLY;
164 } else
165 close(fd);
Theodore Ts'o997b8202001-06-15 18:33:43 +0000166 (void) unlink(TEST_FILE);
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000167 }
Theodore Ts'o2038b632001-09-14 07:44:25 -0400168 retval = 0;
Theodore Ts'o48e6e812003-07-06 00:36:48 -0400169errout:
Theodore Ts'occ860172001-05-25 16:32:53 +0000170 endmntent (f);
Theodore Ts'o2038b632001-09-14 07:44:25 -0400171 return retval;
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000172}
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000173
174static errcode_t check_mntent(const char *file, int *mount_flags,
175 char *mtpt, int mtlen)
176{
177 errcode_t retval;
178
Theodore Ts'o2038b632001-09-14 07:44:25 -0400179#ifdef DEBUG
180 retval = check_mntent_file("/tmp/mtab", file, mount_flags,
181 mtpt, mtlen);
182 if (retval == 0)
183 return 0;
Theodore Ts'of0efd292002-04-27 17:07:52 -0400184#endif /* DEBUG */
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000185#ifdef __linux__
186 retval = check_mntent_file("/proc/mounts", file, mount_flags,
187 mtpt, mtlen);
Theodore Ts'o3a42fe22002-10-31 13:23:37 -0500188 if (retval == 0 && (*mount_flags != 0))
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000189 return 0;
Theodore Ts'of0efd292002-04-27 17:07:52 -0400190#endif /* __linux__ */
Theodore Ts'o5818d672002-06-27 21:19:45 -0400191#if defined(MOUNTED) || defined(_PATH_MOUNTED)
192#ifndef MOUNTED
193#define MOUNTED _PATH_MOUNTED
194#endif /* MOUNTED */
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000195 retval = check_mntent_file(MOUNTED, file, mount_flags, mtpt, mtlen);
196 return retval;
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400197#else
Theodore Ts'o5818d672002-06-27 21:19:45 -0400198 *mount_flags = 0;
199 return 0;
200#endif /* defined(MOUNTED) || defined(_PATH_MOUNTED) */
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000201}
202
Theodore Ts'o48e6e812003-07-06 00:36:48 -0400203#else
204#if defined(HAVE_GETMNTINFO)
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000205
Theodore Ts'o43ec8732001-01-03 14:56:46 +0000206static errcode_t check_getmntinfo(const char *file, int *mount_flags,
207 char *mtpt, int mtlen)
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000208{
209 struct statfs *mp;
210 int len, n;
211 const char *s1;
212 char *s2;
213
214 n = getmntinfo(&mp, MNT_NOWAIT);
215 if (n == 0)
216 return errno;
217
218 len = sizeof(_PATH_DEV) - 1;
219 s1 = file;
220 if (strncmp(_PATH_DEV, s1, len) == 0)
221 s1 += len;
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400222
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000223 *mount_flags = 0;
224 while (--n >= 0) {
225 s2 = mp->f_mntfromname;
226 if (strncmp(_PATH_DEV, s2, len) == 0) {
227 s2 += len - 1;
228 *s2 = 'r';
229 }
230 if (strcmp(s1, s2) == 0 || strcmp(s1, &s2[1]) == 0) {
231 *mount_flags = EXT2_MF_MOUNTED;
232 break;
233 }
234 ++mp;
235 }
Theodore Ts'o43ec8732001-01-03 14:56:46 +0000236 if (mtpt)
237 strncpy(mtpt, mp->f_mntonname, mtlen);
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000238 return 0;
239}
240#endif /* HAVE_GETMNTINFO */
Theodore Ts'ob24efa22012-04-05 15:31:09 -0700241#endif /* HAVE_SETMNTENT */
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000242
243/*
Theodore Ts'of0efd292002-04-27 17:07:52 -0400244 * Check to see if we're dealing with the swap device.
245 */
246static int is_swap_device(const char *file)
247{
248 FILE *f;
249 char buf[1024], *cp;
250 dev_t file_dev;
251 struct stat st_buf;
252 int ret = 0;
253
254 file_dev = 0;
255#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
256 if ((stat(file, &st_buf) == 0) &&
257 S_ISBLK(st_buf.st_mode))
258 file_dev = st_buf.st_rdev;
259#endif /* __GNU__ */
260
261 if (!(f = fopen("/proc/swaps", "r")))
262 return 0;
263 /* Skip the first line */
Karel Zak5f915612009-10-13 13:52:59 +0000264 if (!fgets(buf, sizeof(buf), f))
265 goto leave;
266 if (*buf && strncmp(buf, "Filename\t", 9))
267 /* Linux <=2.6.19 contained a bug in the /proc/swaps
268 * code where the header would not be displayed
269 */
270 goto valid_first_line;
271
Dmitry V. Levind9039ae2007-10-20 22:08:40 +0400272 while (fgets(buf, sizeof(buf), f)) {
Karel Zak5f915612009-10-13 13:52:59 +0000273valid_first_line:
Theodore Ts'of0efd292002-04-27 17:07:52 -0400274 if ((cp = strchr(buf, ' ')) != NULL)
275 *cp = 0;
276 if ((cp = strchr(buf, '\t')) != NULL)
277 *cp = 0;
278 if (strcmp(buf, file) == 0) {
279 ret++;
280 break;
281 }
282#ifndef __GNU__
283 if (file_dev && (stat(buf, &st_buf) == 0) &&
284 S_ISBLK(st_buf.st_mode) &&
285 file_dev == st_buf.st_rdev) {
286 ret++;
287 break;
288 }
289#endif /* __GNU__ */
290 }
Karel Zak5f915612009-10-13 13:52:59 +0000291
292leave:
Theodore Ts'of0efd292002-04-27 17:07:52 -0400293 fclose(f);
294 return ret;
295}
296
297
298/*
Theodore Ts'o2fa8f372005-06-05 16:05:22 -0400299 * ext2fs_check_mount_point() fills determines if the device is
300 * mounted or otherwise busy, and fills in mount_flags with one or
301 * more of the following flags: EXT2_MF_MOUNTED, EXT2_MF_ISROOT,
302 * EXT2_MF_READONLY, EXT2_MF_SWAP, and EXT2_MF_BUSY. If mtpt is
303 * non-NULL, the directory where the device is mounted is copied to
304 * where mtpt is pointing, up to mtlen characters.
Theodore Ts'o43ec8732001-01-03 14:56:46 +0000305 */
306#ifdef __TURBOC__
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000307 #pragma argsused
Theodore Ts'o43ec8732001-01-03 14:56:46 +0000308#endif
309errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
310 char *mtpt, int mtlen)
311{
Theodore Ts'o2fa8f372005-06-05 16:05:22 -0400312 errcode_t retval = 0;
Theodore Ts'o2fa8f372005-06-05 16:05:22 -0400313
Theodore Ts'o07cefe72001-12-24 15:20:22 -0500314 if (is_swap_device(device)) {
315 *mount_flags = EXT2_MF_MOUNTED | EXT2_MF_SWAP;
316 strncpy(mtpt, "<swap>", mtlen);
Theodore Ts'o2fa8f372005-06-05 16:05:22 -0400317 } else {
Theodore Ts'ob24efa22012-04-05 15:31:09 -0700318#ifdef HAVE_SETMNTENT
Theodore Ts'o2fa8f372005-06-05 16:05:22 -0400319 retval = check_mntent(device, mount_flags, mtpt, mtlen);
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400320#else
Theodore Ts'o43ec8732001-01-03 14:56:46 +0000321#ifdef HAVE_GETMNTINFO
Theodore Ts'o2fa8f372005-06-05 16:05:22 -0400322 retval = check_getmntinfo(device, mount_flags, mtpt, mtlen);
Theodore Ts'o43ec8732001-01-03 14:56:46 +0000323#else
Theodore Ts'oed78c022003-03-06 11:09:18 -0500324#ifdef __GNUC__
Theodore Ts'o48e6e812003-07-06 00:36:48 -0400325 #warning "Can't use getmntent or getmntinfo to check for mounted filesystems!"
Theodore Ts'oed78c022003-03-06 11:09:18 -0500326#endif
Theodore Ts'o2fa8f372005-06-05 16:05:22 -0400327 *mount_flags = 0;
Theodore Ts'o43ec8732001-01-03 14:56:46 +0000328#endif /* HAVE_GETMNTINFO */
Theodore Ts'ob24efa22012-04-05 15:31:09 -0700329#endif /* HAVE_SETMNTENT */
Theodore Ts'o2fa8f372005-06-05 16:05:22 -0400330 }
331 if (retval)
332 return retval;
333
334#ifdef __linux__ /* This only works on Linux 2.6+ systems */
Andreas Dilger1d6fd6d2012-11-29 05:47:52 -0700335 {
336 struct stat st_buf;
337
338 if (stat(device, &st_buf) == 0 && S_ISBLK(st_buf.st_mode)) {
339 int fd = open(device, O_RDONLY | O_EXCL);
340
341 if (fd >= 0)
342 close(fd);
343 else if (errno == EBUSY)
344 *mount_flags |= EXT2_MF_BUSY;
345 }
346 }
Matthias Andree406ba672006-05-30 16:28:22 +0200347#endif
Theodore Ts'o2fa8f372005-06-05 16:05:22 -0400348
349 return 0;
Theodore Ts'o43ec8732001-01-03 14:56:46 +0000350}
351
352/*
Theodore Ts'o6bd13482001-06-14 07:00:55 +0000353 * ext2fs_check_if_mounted() sets the mount_flags EXT2_MF_MOUNTED,
Theodore Ts'od5f858d2001-05-25 17:14:23 +0000354 * EXT2_MF_READONLY, and EXT2_MF_ROOT
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400355 *
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000356 */
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000357errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags)
358{
Theodore Ts'od5f858d2001-05-25 17:14:23 +0000359 return ext2fs_check_mount_point(file, mount_flags, NULL, 0);
Theodore Ts'o50e1e101997-04-26 13:58:21 +0000360}
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000361
362#ifdef DEBUG
363int main(int argc, char **argv)
364{
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000365 int retval, mount_flags;
Theodore Ts'oa8fd6e32001-12-24 01:40:35 -0500366 char mntpt[80];
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400367
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000368 if (argc < 2) {
369 fprintf(stderr, "Usage: %s device\n", argv[0]);
370 exit(1);
371 }
372
Theodore Ts'o04f13d62009-09-08 21:33:03 -0400373 add_error_table(&et_ext2_error_table);
Theodore Ts'oa8fd6e32001-12-24 01:40:35 -0500374 mntpt[0] = 0;
375 retval = ext2fs_check_mount_point(argv[1], &mount_flags,
376 mntpt, sizeof(mntpt));
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000377 if (retval) {
378 com_err(argv[0], retval,
379 "while calling ext2fs_check_if_mounted");
380 exit(1);
381 }
382 printf("Device %s reports flags %02x\n", argv[1], mount_flags);
Theodore Ts'o2fa8f372005-06-05 16:05:22 -0400383 if (mount_flags & EXT2_MF_BUSY)
384 printf("\t%s is apparently in use.\n", argv[1]);
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000385 if (mount_flags & EXT2_MF_MOUNTED)
Theodore Ts'occ860172001-05-25 16:32:53 +0000386 printf("\t%s is mounted.\n", argv[1]);
Theodore Ts'o07cefe72001-12-24 15:20:22 -0500387 if (mount_flags & EXT2_MF_SWAP)
388 printf("\t%s is a swap device.\n", argv[1]);
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000389 if (mount_flags & EXT2_MF_READONLY)
Theodore Ts'occ860172001-05-25 16:32:53 +0000390 printf("\t%s is read-only.\n", argv[1]);
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000391 if (mount_flags & EXT2_MF_ISROOT)
Theodore Ts'occ860172001-05-25 16:32:53 +0000392 printf("\t%s is the root filesystem.\n", argv[1]);
Theodore Ts'oa8fd6e32001-12-24 01:40:35 -0500393 if (mntpt[0])
394 printf("\t%s is mounted on %s.\n", argv[1], mntpt);
Theodore Ts'o52db0b42001-04-17 02:22:05 +0000395 exit(0);
396}
Theodore Ts'of0efd292002-04-27 17:07:52 -0400397#endif /* DEBUG */