Patchwork [2/3] libmtd_legacy: don't open device in R/W

login
register
mail settings
Submitter Brian Norris
Date Feb. 8, 2012, 9:26 p.m.
Message ID <1328736382-5798-2-git-send-email-computersforpeace@gmail.com>
Download mbox | patch
Permalink /patch/140263/
State Accepted
Commit ac10be41ad321752682f2549ebc42b2512012f60
Headers show

Comments

Brian Norris - Feb. 8, 2012, 9:26 p.m.
On legacy kernels with ROM devices, we can get mtdinfo errors like:

libmtd: error!: cannot open "/dev/mtd4"
        error 13 (Permission denied)
mtdinfo: error!: libmtd failed get MTD device 4 information
         error 13 (Permission denied)

We don't need O_RDRW access for informational ioctls(), so make this
O_RDONLY.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 lib/libmtd_legacy.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/lib/libmtd_legacy.c b/lib/libmtd_legacy.c
index d3f1672..1ae9946 100644
--- a/lib/libmtd_legacy.c
+++ b/lib/libmtd_legacy.c
@@ -262,7 +262,7 @@  int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd)
 
 	mtd->mtd_num = mtd->minor / 2;
 
-	fd = open(node, O_RDWR);
+	fd = open(node, O_RDONLY);
 	if (fd == -1)
 		return sys_errmsg("cannot open \"%s\"", node);