0

Linuxtopia's Kernel Configuration book recommends the following:

To determine which version of e2fsprogs you have on your system, run the following command:
$ tune2fs

This seems kind of funky, though.

Does e2fsprogs have a canonical way to check the version, or is that as good as it gets?

Wayne Werner
  • 11,463
  • 8
  • 29
  • 43

3 Answers3

4

tune2fs is one of the few e2fsprogs programs which prints its version and exits when given nothing to do (the others are dumpe2fs and resize2fs), and it’s been part of e2fsprogs for a very long time (probably since the beginning). It is therefore a reliable way of determining the installed version of e2fsprogs.

There’s no “official” description of how to determine the installed version of e2fsprogs in its documentation, as far as I can determine.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
1

It does seem kind of funky. If you don't like remembering to use tune2fs, you could instead check the e2fsprogs package you installed.

If you installed it from source code, you can probably check the source very easily. (The version number in the tarball name, or a NEWS / Changelog file).

If you installed it from a distribution package, there are some nice commands for this. It depends exactly how your distribution is set up:

# Debian / Ubuntu
dpkg -l e2fsprogs

# alternatively
sudo which mkfs.ext4
dpkg -S /sbin/mkfs.ext4

# Fedora
rpm -q e2fsprogs

# alternatively
which mkfs.ext4
rpm -q --whatprovides /usr/sbin/mkfs.ext4

# ...
sourcejedi
  • 48,311
  • 17
  • 143
  • 296
1

That's the common way, a potential problem is that the binaries are in /sbin and not all users may be able to run them.

I checked a couple of projects that were likely candidate to use (parts of) e2fsprogs, like gparted - at best they really only care about the presence of libuuid and don't have any autoconf detection of e2fsprogs, or its version.

The libext2fs library exports the function ext2fs_get_library_version(), so to do this robustly:

/* gcc -lext2fs -o gete2ver gete2ver.c */
#include <stdio.h>
#include <ext2fs/ext2fs.h>

int main(int argc, char *argv[])
{
    const char *e2ver, *e2date;
    int ver;

    ver=ext2fs_get_library_version(&e2ver,&e2date);
    printf("version=%04i %s %s\n",ver,e2ver,e2date);
    return 0;
}

Other options:

  1. e2fsprogs comes with a set of libraries, so you can use pkg-config, e.g.

    pkg-config --modversion ext2fs

    pkg-config --modversion e2p

    (But, some distros may not install enough "developer" material by default)

  2. The translated message catalogues contain metadata in the empty "" msgid:

    LANG=fr_FR gettext e2fsprogs ""

    (But, there's no guarantee any particular language will be installed)

mr.spuratic
  • 9,721
  • 26
  • 41