util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipcs,chmem: fix access() usage
@ 2018-06-25 12:18 Ruediger Meier
  2018-06-25 14:52 ` Ruediger Meier
  0 siblings, 1 reply; 2+ messages in thread
From: Ruediger Meier @ 2018-06-25 12:18 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Some mistakes happened lately when switching from path_exist()
to ul_path_access(). See f09a98de and 8ca31279.

This caused ipcs tests 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    |  2 +-
 sys-utils/ipcutils.c | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys-utils/chmem.c b/sys-utils/chmem.c
index e5eab096a..4a4439a22 100644
--- a/sys-utils/chmem.c
+++ b/sys-utils/chmem.c
@@ -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"));
diff --git a/sys-utils/ipcutils.c b/sys-utils/ipcutils.c
index e6dd0c561..5fe297fd4 100644
--- a/sys-utils/ipcutils.c
+++ b/sys-utils/ipcutils.c
@@ -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);
-- 
2.13.7


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ipcs,chmem: fix access() usage
  2018-06-25 12:18 [PATCH] ipcs,chmem: fix access() usage Ruediger Meier
@ 2018-06-25 14:52 ` Ruediger Meier
  0 siblings, 0 replies; 2+ messages in thread
From: Ruediger Meier @ 2018-06-25 14:52 UTC (permalink / raw)
  To: util-linux

I've submitted this and 2 more trivial fixes via github
https://github.com/karelzak/util-linux/pull/653

On Monday 25 June 2018, Ruediger Meier wrote:
> From: Ruediger Meier <ruediger.meier@ga-group.nl>
>
> Some mistakes happened lately when switching from path_exist()
> to ul_path_access(). See f09a98de and 8ca31279.
>
> This caused ipcs tests 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.
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-25 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-25 12:18 [PATCH] ipcs,chmem: fix access() usage Ruediger Meier
2018-06-25 14:52 ` Ruediger Meier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).