]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: remove unnecessary fstat() call
authorKarel Zak <kzak@redhat.com>
Fri, 30 Jun 2017 09:29:47 +0000 (11:29 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 14 Jul 2017 09:33:30 +0000 (11:33 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/context.c

index 9d5492be73878d6422bc92996ae5e4d289b48b9b..e8dfa0e691471b823fe330d74e6fe0fc4d7c316c 100644 (file)
@@ -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