From: Eric Sandeen <sandeen@sandeen.net>
To: xfs-oss <xfs@oss.sgi.com>
Cc: Theodore Tso <tytso@mit.edu>
Subject: [PATCH] xfstests: fix up fs_perms test used by 126
Date: Fri, 05 Feb 2010 10:59:45 -0600 [thread overview]
Message-ID: <4B6C4E81.6060201@sandeen.net> (raw)
Test 126 was failing intermittently for Ted & I; it seems that
this is because we were passing an unterminated string to
fopen for the mode; I'm not certain why this made it fail,
but it's pretty clearly not a good thing to do, and fixing
it fixes the test.
Rather than passing around characters, do things string-wise,
since that is what is ultimately used in fopen().
Also make it at least possible to pass in the 2-character
modes fopen can take (r+, w+, etc), I suppose testcases
could be added for this later.
Reported-by: Theodore Tso <tytso@mit.edu>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---
diff --git a/src/fs_perms.c b/src/fs_perms.c
index 2c5e3fa..f34c4f4 100644
--- a/src/fs_perms.c
+++ b/src/fs_perms.c
@@ -42,7 +42,7 @@ int testsetup(mode_t mode, int cuserId, int cgroupId);
int testfperm(int userId, int groupId, char* fperm);
int main( int argc, char *argv[]) {
- char fperm[1];
+ char fperm[3];
int result, exresult=0, cuserId=0, cgroupId=0, userId=0, groupId=0;
mode_t mode;
@@ -53,7 +53,8 @@ int main( int argc, char *argv[]) {
cgroupId = atoi(argv[3]);
userId = atoi(argv[4]);
groupId = atoi(argv[5]);
- fperm[0] = *argv[6];
+ strncpy(fperm, argv[6], 3);
+ fperm[2] = '\0';
exresult = atoi(argv[7]);
break;
default:
@@ -64,7 +65,7 @@ int main( int argc, char *argv[]) {
testsetup(mode,cuserId,cgroupId);
result=testfperm(userId,groupId,fperm);
system("rm test.file");
- printf("%c a %03o file owned by (%d/%d) as user/group(%d/%d) ",fperm[0],mode,cuserId,cgroupId,userId,groupId);
+ printf("%s a %03o file owned by (%d/%d) as user/group(%d/%d) ",fperm,mode,cuserId,cgroupId,userId,groupId);
if (result == exresult) {
printf("PASS\n");
exit(0);
@@ -102,8 +103,7 @@ int testfperm(int userId, int groupId, char* fperm) {
return(-1);
}
- switch(tolower(fperm[0])) {
- case 'x':
+ if (!strcmp("x", fperm)) {
PID = fork();
if (PID == 0) {
execlp("./test.file","test.file",NULL);
@@ -114,8 +114,7 @@ int testfperm(int userId, int groupId, char* fperm) {
seteuid(0);
setegid(0);
return(nuthertmpi);
-
- default:
+ } else {
if((testfile=fopen("test.file",fperm))){
fclose(testfile);
seteuid(0);
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2010-02-05 16:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-05 16:59 Eric Sandeen [this message]
2010-02-08 19:40 ` [PATCH] xfstests: fix up fs_perms test used by 126 Christoph Hellwig
2010-02-08 19:47 ` Eric Sandeen
2010-02-09 16:54 ` [PATCH V2] " Eric Sandeen
2010-02-09 17:53 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B6C4E81.6060201@sandeen.net \
--to=sandeen@sandeen.net \
--cc=tytso@mit.edu \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox