rmobj() is failing for _64 version of testcases, which use large
files, where it hits EOVERFLOW in lstat():
open12 0 TWARN : tst_tmpdir.c:206: tst_rmdir: rmobj(/tmp/opexIqjV3)
failed:
lstat(/tmp/opexIqjV3/large_file) failed; errno=75:
Value too large for defined data type
Avoid using any *stat functions, instead try to open "obj"
with open(O_DIRECTORY | O_NOFOLLOW,..). If it succeeds,
we know we are dealing with directory, otherwise assume
it's a file or symlink.
Signed-off-by: Jan Stancek <[email protected]>
---
lib/rmobj.c | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/lib/rmobj.c b/lib/rmobj.c
index 9b6a643..9322fa9 100644
--- a/lib/rmobj.c
+++ b/lib/rmobj.c
@@ -84,6 +84,7 @@
#include <limits.h> /* for PATH_MAX */
#include <sys/types.h> /* for opendir(), readdir(), closedir(), stat()
*/
#include <sys/stat.h> /* for [l]stat() */
+#include <fcntl.h>
#include <dirent.h> /* for opendir(), readdir(), closedir() */
#include <unistd.h> /* for rmdir(), unlink() */
#include "rmobj.h"
@@ -98,19 +99,13 @@ int rmobj(char *obj, char **errmsg)
char dirobj[PATH_MAX]; /* object inside directory to modify */
struct stat statbuf; /* used to hold stat information */
static char err_msg[1024]; /* error message */
+ int fd;
/* Determine the file type */
- if (lstat(obj, &statbuf) < 0) {
- if (errmsg != NULL) {
- sprintf(err_msg, "lstat(%s) failed; errno=%d: %s",
- obj, errno, SYSERR);
- *errmsg = err_msg;
- }
- return -1;
- }
- /* Take appropriate action, depending on the file type */
- if ((statbuf.st_mode & S_IFMT) == S_IFDIR) {
+ fd = open(obj, O_DIRECTORY | O_NOFOLLOW);
+ if (fd != -1) {
+ close(fd);
/* object is a directory */
/* Do NOT perform the request if the directory is "/" */
--
1.7.1
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list