From: Mike Frysinger Date: Thu, 2 May 2013 16:33:21 +0000 (-0400) Subject: flash_erase: use pwrite() rather than lseek() && write() X-Git-Tag: v1.5.1~23 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d51d421d1b8f1afcedb8593ce835819c57792f45;p=mtd-utils.git flash_erase: use pwrite() rather than lseek() && write() Saves a syscall. Signed-off-by: Mike Frysinger Signed-off-by: Artem Bityutskiy --- 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; }