[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH 15/21] Add write mode to vg_open(), calling the new vg_read API with READ_FOR_UPDATE.



Signed-off-by: Dave Wysochanski <dwysocha redhat com>
---
 lib/lvm2.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/lvm2.c b/lib/lvm2.c
index cf4e603..e58f7e8 100644
--- a/lib/lvm2.c
+++ b/lib/lvm2.c
@@ -49,14 +49,17 @@ vg_t *lvm_vg_open(lvm_handle_t libh, const char *vg_name, mode_t mode)
 {
 	vg_t *vg;
 
-	if ((mode & O_ACCMODE) != O_RDONLY) {
+	if ((mode & O_ACCMODE) == O_RDONLY) {
+		vg = vg_read(libh->cmd, vg_name, NULL, 0);
+	} else if ((mode & O_ACCMODE) == O_RDWR) {
+		vg = vg_read(libh->cmd, vg_name, NULL, READ_FOR_UPDATE);
+	} else {
 		log_error("Invalid access mode 0x%x for lvm_vg_read()\n",
 			  mode);
 		libh->lvm_errno = EPERM;
 		return NULL;
 	}
-	vg = vg_read(libh->cmd, vg_name, NULL, 0);
-
+	
 	if (vg_read_error(vg)) {
 		/* FIXME: fill in vg->errno */
 		return NULL;
-- 
1.6.0.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]