]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ipcs,chmem: fix access() usage
authorRuediger Meier <ruediger.meier@ga-group.nl>
Mon, 25 Jun 2018 12:01:21 +0000 (14:01 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Mon, 25 Jun 2018 14:49:00 +0000 (16:49 +0200)
Some mistakes happened lately when switching from path_exist()
to ul_path_access(). See f09a98de and 8ca31279.

This caused ipcs test failures when running i386 binaries on x86_64
hosts, because the syscall fallback was always used. That's why I
reviewed all similar changes and found another one in chmem.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
sys-utils/chmem.c
sys-utils/ipcutils.c

index e5eab096a471f371620b6934475327b230194349..4a4439a2222ee1dddbb703ebc7f20761a55d18bd 100644 (file)
@@ -428,7 +428,7 @@ int main(int argc, char **argv)
 
 
        /* The valid_zones sysfs attribute was introduced with kernel 3.18 */
-       if (ul_path_access(desc->sysmem, F_OK, "memory0/valid_zones"))
+       if (ul_path_access(desc->sysmem, F_OK, "memory0/valid_zones") == 0)
                desc->have_zones = 1;
        else if (zone)
                warnx(_("zone ignored, no valid_zones sysfs attribute present"));
index e6dd0c5617ae6c861a204dcd73c772c2f3b7e29a..5fe297fd413ac429430eb3e1ae392b515609b0f9 100644 (file)
@@ -18,9 +18,9 @@
 
 int ipc_msg_get_limits(struct ipc_limits *lim)
 {
-       if (access(_PATH_PROC_IPC_MSGMNI, F_OK) &&
-           access(_PATH_PROC_IPC_MSGMNB, F_OK) &&
-           access(_PATH_PROC_IPC_MSGMAX, F_OK)) {
+       if (access(_PATH_PROC_IPC_MSGMNI, F_OK) == 0 &&
+           access(_PATH_PROC_IPC_MSGMNB, F_OK) == 0 &&
+           access(_PATH_PROC_IPC_MSGMAX, F_OK) == 0) {
 
                ul_path_read_s32(NULL, &lim->msgmni, _PATH_PROC_IPC_MSGMNI);
                ul_path_read_s32(NULL, &lim->msgmnb, _PATH_PROC_IPC_MSGMNB);
@@ -71,9 +71,9 @@ int ipc_shm_get_limits(struct ipc_limits *lim)
 {
        lim->shmmin = SHMMIN;
 
-       if (access(_PATH_PROC_IPC_SHMALL, F_OK) &&
-           access(_PATH_PROC_IPC_SHMMAX, F_OK) &&
-           access(_PATH_PROC_IPC_SHMMNI, F_OK)) {
+       if (access(_PATH_PROC_IPC_SHMALL, F_OK) == 0 &&
+           access(_PATH_PROC_IPC_SHMMAX, F_OK) == 0 &&
+           access(_PATH_PROC_IPC_SHMMNI, F_OK) == 0) {
 
                ul_path_read_u64(NULL, &lim->shmall, _PATH_PROC_IPC_SHMALL);
                ul_path_read_u64(NULL, &lim->shmmax, _PATH_PROC_IPC_SHMMAX);