erofs-utils: tar: avoid linux-like hard-coded makedev()
PATCH 1/1 erofs-utils: tar: avoid linux-like hard-coded makedev()
This code needs a way to construct a valid st_rdev (dev_t) from major and minor device numbers, so that erofs_new_encode_dev() can later convert the dev_t into the EROFS on-disk rdev format.
But it never uses makedev() to generate dev_t; instead, erofs_new_encode_dev() uses major()/minor(), so the usage is unpaired and the original one works only on the Linux platform and non-portable.
Reported-by Kern Walster <[email protected]>
Fixes 95d315fd7958 ("erofs-utils: introduce tarerofs")
Cc Derek McGowan <[email protected]>
Signed-off-by Gao Xiang <[email protected]>
--- lib/tar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/tar.c +4 -1
@@ -11,6 +11,9 @@#include "erofs/xattr.h" #include "erofs/blobchunk.h" #include "erofs/importer.h" +#if defined(HAVE_SYS_SYSMACROS_H ) +#include <sys/sysmacros.h> +#endif #if defined(HAVE_ZLIB )#include <zlib.h> #endif
@@ -957,7 +960,7 @@ out_eot: goto out; } - st.st_rdev = (major <<8 ) | (minor &0xff ) | ((minor & ~0xff ) <<12 ); + st.st_rdev =makedev (major, minor); }else if (th->typeflag =='1' || th->typeflag =='2' ) {if (!eh.link) eh.link =strndup (th->linkname,sizeof (th->linkname));
Signature · 1 line
2.43.5