Whamcloud - gitweb
misc/mk_hugefiles: simplify get_partition_start()
authorEric Biggers <ebiggers@google.com>
Sat, 21 Jan 2023 20:32:23 +0000 (12:32 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 27 Jan 2023 17:38:31 +0000 (12:38 -0500)
commit4d890149b97b7bf76d6c557b42c407be1b138de4
tree372e32bfe986c499aefec6bfb189763c6681456c
parent44ee1fb80bd347ba92c38a4e60060229f671dcd8
misc/mk_hugefiles: simplify get_partition_start()

search_sysfs_block() is causing -Wformat-truncation warnings.  These
could be fixed by checking the return value of snprintf(), instead of
doing buggy checks like 'strlen(p_de->d_name) > SYSFS_PATH_LEN -
strlen(path) - 32', which has an integer underflow bug.

However, the only purpose of search_sysfs_block() is to find the sysfs
directory for a block device by device number.  That can trivially be
done using /sys/dev/block/$major:$minor.  So just do that instead.  Also
make get_partition_start() explicitly Linux-only, as it has never worked
anywhere else.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
include/mingw/sys/sysmacros.h
misc/mk_hugefiles.c