From 2db3cc4cf3245a3522911dfa2a0e569a249d11df Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 30 Jun 2017 11:29:47 +0200 Subject: [PATCH] libfdisk: remove unnecessary fstat() call Signed-off-by: Karel Zak --- libfdisk/src/context.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index 9d5492be73..e8dfa0e691 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -701,14 +701,14 @@ int fdisk_reassign_device(struct fdisk_context *cxt) */ int fdisk_reread_partition_table(struct fdisk_context *cxt) { - int i; - struct stat statbuf; + int i = 0; assert(cxt); assert(cxt->dev_fd >= 0); - i = fstat(cxt->dev_fd, &statbuf); - if (i == 0 && S_ISBLK(statbuf.st_mode)) { + if (!S_ISBLK(cxt->dev_st.st_mode)) + return 0; + else { DBG(CXT, ul_debugobj(cxt, "calling re-read ioctl")); sync(); #ifdef BLKRRPART @@ -732,6 +732,7 @@ int fdisk_reread_partition_table(struct fdisk_context *cxt) return 0; } + /** * fdisk_is_readonly: * @cxt: context -- 2.47.2