hi Oleg, the reasons seems that in this statment "statfs(filename, &st)", the st.f_fsid is set to 0.
so, the memcmp(&st.f_fsid, &st_mnt.f_fsid, sizeof(fsid_t) always return 0, so the first device is matched.
the man page of statfs perhaps relates to this
Nobody knows what f_fsid is supposed to contain (but see below).
Fields that are undefined for a particular file system are set to 0. fstatfs() returns the same informa-
tion about an open file referenced by descriptor fd.