[PATCH] flash_erase: use pwrite() rather than lseek() && write()

Mike Frysinger vapier at gentoo.org
Thu May 2 12:33:21 EDT 2013


Saves a syscall.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 flash_erase.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/flash_erase.c b/flash_erase.c
index 326a299..1421cf9 100644
--- a/flash_erase.c
+++ b/flash_erase.c
@@ -277,11 +277,7 @@ int main(int argc, char *argv[])
 				continue;
 			}
 		} else {
-			if (lseek(fd, offset, SEEK_SET) < 0) {
-				sys_errmsg("%s: MTD lseek failure", mtd_device);
-				continue;
-			}
-			if (write(fd, &cleanmarker, sizeof(cleanmarker)) != sizeof(cleanmarker)) {
+			if (pwrite(fd, &cleanmarker, sizeof(cleanmarker), (loff_t)offset) != sizeof(cleanmarker)) {
 				sys_errmsg("%s: MTD write failure", mtd_device);
 				continue;
 			}
-- 
1.8.2.1




More information about the linux-mtd mailing list