[Lustre-discuss] inconsistent client behavior when creating an empty directory
Andrej Filipcic
andrej.filipcic at ijs.si
Tue Aug 9 06:16:31 PDT 2011
Hi,
the following code does not work as expected:
---------
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
int main(int argc, char** argv) {
int rc;
rc=mkdir(argv[1],S_IRWXU);
if(rc) perror("failed create dir");
chown(argv[1],4103,4100);
struct stat buf;
/* stat(argv[1],&buf); */
setresuid(0,4103,4100);
rc=mkdir(argv[1],S_IRWXU);
if(rc) perror("failed create dir as user");
}
---------
initial status:
# ls -ld /lustre/test
drwxr-xr-x 2 root root 4096 Aug 9 14:59 /lustre/test
# ls -l /lustre/test
total 0
1) running the test program:
# /tmp/test /lustre/test/testdir
failed create dir as user: Permission denied
# ls -l /lustre/test
total 4
drwx------ 2 griduser03 grid 4096 Aug 9 15:02 testdir
griduser03, grid correspond to uid=4103,gid=4100
2) running the test program, but with uncommented stat call:
# /tmp/test /lustre/test/testdir
failed create dir as user: File exists
# ls -l /lustre/test
total 4
drwx------ 2 griduser03 grid 4096 Aug 9 15:04 testdir
The code first makes the testdir as root and changes the ownership to uid 4103.
Then it tries to (re)create the same dir with the user privileges.
If "stat" is called, the code behaves as expected (case 2), but if not (case
1), the second mkdir should return EEXIST and not EACCES. Is this behavior
expected or is it a client bug? The client runs lustre 1.8.6.
The code just illustrates, what is actually used in a complex software.
Andrej
--
_____________________________________________________________
prof. dr. Andrej Filipcic, E-mail: Andrej.Filipcic at ijs.si
Department of Experimental High Energy Physics - F9
Jozef Stefan Institute, Jamova 39, P.o.Box 3000
SI-1001 Ljubljana, Slovenia
Tel.: +386-1-477-3674 Fax: +386-1-477-3166
-------------------------------------------------------------
More information about the lustre-discuss
mailing list