summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/context.c
diff options
context:
space:
mode:
authorKarel Zak2017-06-30 11:29:47 +0200
committerKarel Zak2017-07-14 11:33:30 +0200
commit2db3cc4cf3245a3522911dfa2a0e569a249d11df (patch)
treedc7357a2d41d1c9497a59236a6574e9c28add65d /libfdisk/src/context.c
parentlibfdisk: move fdisk_reread_partition_table() to another file (diff)
downloadkernel-qcow2-util-linux-2db3cc4cf3245a3522911dfa2a0e569a249d11df.tar.gz
kernel-qcow2-util-linux-2db3cc4cf3245a3522911dfa2a0e569a249d11df.tar.xz
kernel-qcow2-util-linux-2db3cc4cf3245a3522911dfa2a0e569a249d11df.zip
libfdisk: remove unnecessary fstat() call
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r--libfdisk/src/context.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 9d5492be7..e8dfa0e69 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