lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 7 Sep 2012 21:12:49 +0100
From:	Mike Fleetwood <mike.fleetwood@...glemail.com>
To:	linux-ext4@...r.kernel.org
Cc:	Mike Fleetwood <mike.fleetwood@...glemail.com>
Subject: How to query ext2/3/4 total fs size while mounted?

Hi,

Is there a way I can/should code GParted (GNOME Partition Editor) to
query a mounted ext2/3/4 file system to get the total file system size?

Unfortunately the f_blocks value from the statvfs() system call has
space occupied by inode tables, allocation bitmaps, etc. subtracted as
overhead and I need the total file system size.  This is so that GParted
can inform users when the file system doesn't fill the partition and
recommend resizing the FS to fix it.

I really want some way to get the the total file system size from
statvfs().  The mount option minixdf isn't really appropriate as GParted
shouldn't be remounting file systems adding mount options to query the
file system size.

Is it safe to read the super block off disk using ext2fs_open() or by
running dumpe2fs for a mounted file system?  What if the file system has
just been resized?  Are there any other methods for querying the total
file system size?

Thanks,
Mike


In this example I want to get the 194560 blocks figure while mounted,
not f_blocks=188403.

# sfdisk -s /dev/sda10
194560
# mkfs.ext4 /dev/sda10
mke2fs 1.41.12 (17-May-2010)
...
48768 inodes, 194560 blocks
...
# dumpe2fs -h /dev/sda10 | grep 'Block count:'
dumpe2fs 1.41.12 (17-May-2010)
Block count:              194560
# mount /dev/sda10 /mnt/0
# strace -e statfs64 stat -f /mnt/0
...
statfs64("/mnt/0", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=1024,
f_blocks=188403, f_bfree=182757, f_bavail=173029, f_files=48768,
f_ffree=48757, f_fsid={-1366779076, -459235834}, f_namelen=255,
f_frsize=1024}) = 0
  File: "/mnt/0"
    ID: ae889b3ce4a09e06 Namelen: 255     Type: ext2/ext3
Block size: 1024       Fundamental block size: 1024
Blocks: Total: 188403     Free: 182757     Available: 173029
Inodes: Total: 48768      Free: 48757
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ