[PATCH 10/16] kpartx: Make kpartx able to create read-only loop devices

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

 



This just passes the read-only value into set_loop, and falls back
to read-only mapping on EACCESS to handle immutable files.

Signed-off-by: Till Maas <opensource@xxxxxxxxx>
Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
 kpartx/kpartx.c | 3 +--
 kpartx/lopart.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
index 1369542..9a9a5eb 100644
--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -205,7 +205,6 @@ main(int argc, char **argv){
 	char * delim = NULL;
 	char *uuid = NULL;
 	char *mapname = NULL;
-	int loopro = 0;
 	int hotplug = 0;
 	int loopcreated = 0;
 	struct stat buf;
@@ -316,7 +315,7 @@ main(int argc, char **argv){
 		if (!loopdev) {
 			loopdev = find_unused_loop_device();
 
-			if (set_loop(loopdev, device, 0, &loopro)) {
+			if (set_loop(loopdev, device, 0, &ro)) {
 				fprintf(stderr, "can't set up loop\n");
 				exit (1);
 			}
diff --git a/kpartx/lopart.c b/kpartx/lopart.c
index 79a7593..9082ca8 100644
--- a/kpartx/lopart.c
+++ b/kpartx/lopart.c
@@ -230,7 +230,7 @@ set_loop (const char *device, const char *file, int offset, int *loopro)
 
 	if ((ffd = open (file, mode)) < 0) {
 
-		if (!*loopro && errno == EROFS)
+		if (!*loopro && (errno == EROFS || errno == EACCES))
 			ffd = open (file, mode = O_RDONLY);
 
 		if (ffd < 0) {
-- 
1.8.4.2

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux