* [PATCH v3 06/11] nilfs-utils: fsck: modify check_mount() function with the purpose of adding opportunity of RO mount checking
@ 2012-09-05 19:54 Vyacheslav Dubeyko
0 siblings, 0 replies; 2+ messages in thread
From: Vyacheslav Dubeyko @ 2012-09-05 19:54 UTC (permalink / raw)
To: linux-nilfs
Hi,
This patch modifies check_mount() function with the purpose of adding opportunity of RO mount checking.
With the best regards,
Vyacheslav Dubeyko.
--
From: Vyacheslav Dubeyko <slava-yeENwD64cLxBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH v3 06/11] nilfs-utils: fsck: modify check_mount() function with the purpose of adding opportunity of RO mount checking
This patch modifies check_mount() function with the purpose of adding opportunity of RO mount checking.
Signed-off-by: Vyacheslav Dubeyko <slava-yeENwD64cLxBDgjK7y7TUQ@public.gmane.org>
---
lib/ismounted.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/lib/ismounted.c b/lib/ismounted.c
index 7c5f0fc..d16dce9 100644
--- a/lib/ismounted.c
+++ b/lib/ismounted.c
@@ -31,6 +31,15 @@
#define LINE_BUFFER_SIZE 256 /* Line buffer size for reading mtab */
+/*
+ * check_mount - Check that device mounted or not.
+ * @device: pointer on device.
+ *
+ * Return value:
+ * 0 - device is not mounted.
+ * -1 - device is mounted in RW mode.
+ * -2 - device is mounted in RO mode.
+ */
int check_mount(const char *device)
{
struct mntent *mnt;
@@ -38,6 +47,7 @@ int check_mount(const char *device)
FILE *f;
dev_t file_dev = 0, file_rdev = 0;
ino_t file_ino = 0;
+ int mount_type = 0;
f = setmntent(_PATH_MOUNTED, "r");
if (f == NULL) {
@@ -71,6 +81,9 @@ int check_mount(const char *device)
}
}
+ if (mnt)
+ mount_type = (hasmntopt(mnt, MNTOPT_RO)) ? -2 : -1;
+
endmntent(f);
- return (mnt == NULL) ? 0 : -1;
+ return (mnt == NULL) ? 0 : mount_type;
}
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v3 06/11] nilfs-utils: fsck: modify check_mount() function with the purpose of adding opportunity of RO mount checking
@ 2012-09-05 19:14 Vyacheslav Dubeyko
0 siblings, 0 replies; 2+ messages in thread
From: Vyacheslav Dubeyko @ 2012-09-05 19:14 UTC (permalink / raw)
To: linux-nilfs
Hi,
This patch modifies check_mount() function with the purpose of adding opportunity of RO mount checking.
With the best regards,
Vyacheslav Dubeyko.
--
From: Vyacheslav Dubeyko <slava-yeENwD64cLxBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH v3 06/11] nilfs-utils: fsck: modify check_mount() function with the purpose of adding opportunity of RO mount checking
This patch modifies check_mount() function with the purpose of adding opportunity of RO mount checking.
Signed-off-by: Vyacheslav Dubeyko <slava-yeENwD64cLxBDgjK7y7TUQ@public.gmane.org>
---
lib/ismounted.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/lib/ismounted.c b/lib/ismounted.c
index 7c5f0fc..d16dce9 100644
--- a/lib/ismounted.c
+++ b/lib/ismounted.c
@@ -31,6 +31,15 @@
#define LINE_BUFFER_SIZE 256 /* Line buffer size for reading mtab */
+/*
+ * check_mount - Check that device mounted or not.
+ * @device: pointer on device.
+ *
+ * Return value:
+ * 0 - device is not mounted.
+ * -1 - device is mounted in RW mode.
+ * -2 - device is mounted in RO mode.
+ */
int check_mount(const char *device)
{
struct mntent *mnt;
@@ -38,6 +47,7 @@ int check_mount(const char *device)
FILE *f;
dev_t file_dev = 0, file_rdev = 0;
ino_t file_ino = 0;
+ int mount_type = 0;
f = setmntent(_PATH_MOUNTED, "r");
if (f == NULL) {
@@ -71,6 +81,9 @@ int check_mount(const char *device)
}
}
+ if (mnt)
+ mount_type = (hasmntopt(mnt, MNTOPT_RO)) ? -2 : -1;
+
endmntent(f);
- return (mnt == NULL) ? 0 : -1;
+ return (mnt == NULL) ? 0 : mount_type;
}
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-05 19:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-05 19:54 [PATCH v3 06/11] nilfs-utils: fsck: modify check_mount() function with the purpose of adding opportunity of RO mount checking Vyacheslav Dubeyko
-- strict thread matches above, loose matches on Subject: below --
2012-09-05 19:14 Vyacheslav Dubeyko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.