Reintroduce f_type comparison macro
This reverts commit 4826f0b7b5.
Because statfs.t_type can be int on some architecures, we have to cast
the const magic to the type, otherwise the compiler warns about
signed/unsigned comparison, because the magic can be 32 bit unsigned.
statfs(2) man page is also wrong on some systems, because
f_type is not __SWORD_TYPE on some architecures.
The following program:
int main(int argc, char**argv)
{
struct statfs s;
statfs(argv[1], &s);
printf("sizeof(f_type) = %d\n", sizeof(s.f_type));
printf("sizeof(__SWORD_TYPE) = %d\n", sizeof(__SWORD_TYPE));
printf("sizeof(long) = %d\n", sizeof(long));
printf("sizeof(int) = %d\n", sizeof(int));
if (sizeof(s.f_type) == sizeof(int)) {
printf("f_type = 0x%x\n", s.f_type);
} else {
printf("f_type = 0x%lx\n", s.f_type);
}
return 0;
}
executed on s390x gives for a btrfs:
sizeof(f_type) = 4
sizeof(__SWORD_TYPE) = 8
sizeof(long) = 8
sizeof(int) = 4
f_type = 0x9123683e
This commit is contained in:
@@ -1251,11 +1251,11 @@ static void check_network(sd_journal *j, int fd) {
|
||||
return;
|
||||
|
||||
j->on_network =
|
||||
sfs.f_type == (__SWORD_TYPE) CIFS_MAGIC_NUMBER ||
|
||||
sfs.f_type == (__SWORD_TYPE) CODA_SUPER_MAGIC ||
|
||||
sfs.f_type == (__SWORD_TYPE) NCP_SUPER_MAGIC ||
|
||||
sfs.f_type == (__SWORD_TYPE) NFS_SUPER_MAGIC ||
|
||||
sfs.f_type == (__SWORD_TYPE) SMB_SUPER_MAGIC;
|
||||
F_TYPE_CMP(sfs.f_type, CIFS_MAGIC_NUMBER) ||
|
||||
F_TYPE_CMP(sfs.f_type, CODA_SUPER_MAGIC) ||
|
||||
F_TYPE_CMP(sfs.f_type, NCP_SUPER_MAGIC) ||
|
||||
F_TYPE_CMP(sfs.f_type, NFS_SUPER_MAGIC) ||
|
||||
F_TYPE_CMP(sfs.f_type, SMB_SUPER_MAGIC);
|
||||
}
|
||||
|
||||
static int add_file(sd_journal *j, const char *prefix, const char *filename) {
|
||||
|
||||
Reference in New Issue
Block a user