nanddump: make dumping read-only partitions work
authorMatt Reimer <mreimer@sdgsystems.com>
Wed, 30 May 2012 14:31:13 +0000 (10:31 -0400)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 13 Jun 2012 00:39:22 +0000 (02:39 +0200)
Make dumping read-only partitions work by opening the device
O_RDONLY; otherwise the open() will fail with -EPERM.

Signed-off-by: Matt Reimer <mreimer@sdgsystems.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/nandwrite.c

index 2ba6e3fe55c280883a45e7b13f84bb4c25a80dbd..c636a5aa205c8d40fa268f5e885f21661e4d5c9b 100644 (file)
@@ -129,7 +129,7 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
                xmove_fd(tmp_fd, IS_NANDDUMP ? STDOUT_FILENO : STDIN_FILENO);
        }
 
-       fd = xopen(argv[0], O_RDWR);
+       fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY);
        xioctl(fd, MEMGETINFO, &meminfo);
 
        mtdoffset = xstrtou(opt_s, 0);