Skip to contentSkip to conversation

syscall/dup03: Close all open files in cleanup

PATCH In review Eryu Guan 3 participants 3 messages Nov 11, 2011

lore
Share & tools
lore

Eryu Guan

author
#0 lore raw

PATCH 1/1 syscall/dup03: Close all open files in cleanup

The 'silly rename' mechanism of NFS creates temporary file .nfsXXX in NFS mount. The cleanup() in dup03.c doesn't close all open files and leaves .nfsXXX file in the testing directory. Then rmdir(2) complains about "Directory not empty".

dup03       1  TPASS  :  dup failed as expected with EMFILE
dup03       0  TWARN  :  tst_rmdir: rmobj(/mnt/nfs/dupxesX9v) failed: remove(/mnt/nfs/dupxesX9v) failed; errno=39: Directory not empty

So close all open files in cleanup().

---
 testcases/kernel/syscalls/dup/dup03.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/dup/dup03.c +2 -2
index 0b82956..6f29c21 100644
@@ -217,8 +217,8 @@ void cleanup()
 
 	TEST_CLEANUP;
 
-	for (i = 3; i <= nfds; i++)
+	for (i = 0; i <= nfds; i++)
 		close(fd[i]);
 
 	tst_rmdir();
-}
\ No newline at end of file
+}

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Eryu Guan

The 'silly rename' mechanism of NFS creates temporary file .nfsXXX in NFS mount. The cleanup() in dup03.c doesn't close all open files and leaves .nfsXXX file in the testing directory. Then rmdir(2) complains about "Directory not empty".

Quoted 6 lines
dup03       1  TPASS  :  dup failed as expected with EMFILE
dup03       0  TWARN  :  tst_rmdir: rmobj(/mnt/nfs/dupxesX9v) failed: remove(/mnt/nfs/dupxesX9v) failed; errno=39: Directory not empty

So close all open files in cleanup().

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
In reply to Eryu Guan

Hi!

Quoted 4 lines

The 'silly rename' mechanism of NFS creates temporary file .nfsXXX in NFS mount. The cleanup() in dup03.c doesn't close all open files and leaves .nfsXXX file in the testing directory. Then rmdir(2) complains about "Directory not empty".

Comited, thanks.

Signature · 12 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list