summaryrefslogtreecommitdiff
path: root/libbb/loop.c
diff options
context:
space:
mode:
authorRob Landley2005-10-11 07:26:15 +0000
committerRob Landley2005-10-11 07:26:15 +0000
commitff567f7943f50b88dea14cd27636168ba2d319b5 (patch)
tree78de3691d83082ad26c2b2c02cc60d46bd912ed8 /libbb/loop.c
parent554a9ff7eaf60bcb960a5f0670a9ed74db2f3292 (diff)
downloadbusybox-ff567f7943f50b88dea14cd27636168ba2d319b5.zip
busybox-ff567f7943f50b88dea14cd27636168ba2d319b5.tar.gz
The check for EROFS was wrong. For example, if you try to mount a filesystem
appended to an executable that's being run (yes, I'm doing this) you get EPERM, but mounting readonly fixes it. Doing the fallback all the time shouldn't hurt, and is one less test.
Diffstat (limited to 'libbb/loop.c')
-rw-r--r--libbb/loop.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libbb/loop.c b/libbb/loop.c
index 25f66fc..f7029d5 100644
--- a/libbb/loop.c
+++ b/libbb/loop.c
@@ -88,10 +88,9 @@ extern int set_loop(char **device, const char *file, int offset)
int i, dfd, ffd, mode, rc=1;
// Open the file. Barf if this doesn't work.
- if((ffd = open(file, mode=O_RDWR))<0)
- if(errno!=EROFS || (ffd=open(file,mode=O_RDONLY))<0)
- return errno;
-
+ if((ffd = open(file, mode=O_RDWR))<0 && (ffd = open(file,mode=O_RDONLY))<0)
+ return errno;
+
// Find a loop device
for(i=0;rc;i++) {
sprintf(dev, LOOP_FORMAT, i++);