Skip to contentSkip to conversation

flash_erase: use pwrite() rather than lseek() && write()

PATCH Applied Mike Frysinger 2 participants 2 messages May 2, 2013 – May 29, 2013 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 flash_erase: use pwrite() rather than lseek() && write()

Saves a syscall.

---
 flash_erase.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
flash_erase.c +1 -5
index 326a299..1421cf9 100644
@@ -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;
 			}
Signature · 1 line
1.8.2.1