public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] device-drivers/acpi/ltp_acpi_cpufreq: fix checking for write permission
@ 2014-05-07 13:16 Alexey Kodanev
  2014-05-12 13:39 ` chrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Kodanev @ 2014-05-07 13:16 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

If access(some_file, W_OK) is executed by root it will return success even
if the file has read-only permission. Use 'open' to test sysfs file for write
permission.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 .../kernel/device-drivers/acpi/ltp_acpi_cpufreq.c  |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c b/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c
index 175bf4c..f1d3d5a 100644
--- a/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c
+++ b/testcases/kernel/device-drivers/acpi/ltp_acpi_cpufreq.c
@@ -31,6 +31,9 @@
 #include <sched.h>
 #include <sys/time.h>
 #include <pthread.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 
 #include "test.h"
 #include "usctest.h"
@@ -69,12 +72,15 @@ static void cleanup(void)
 
 static void setup(void)
 {
+	int fd;
 	tst_require_root(NULL);
 
-	if (access(boost, R_OK | W_OK)) {
+	fd = open(boost, O_RDWR);
+	if (fd == -1) {
 		tst_brkm(TCONF, NULL,
 			"acpi-cpufreq not loaded or overclock not supported");
 	}
+	close(fd);
 
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
-- 
1.7.1


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2014-05-12 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-07 13:16 [LTP] [PATCH] device-drivers/acpi/ltp_acpi_cpufreq: fix checking for write permission Alexey Kodanev
2014-05-12 13:39 ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox