diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2014-10-28 14:57:53 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2014-10-28 14:57:53 +0000 |
commit | af1789055445dd0a96fd357b570f975640eb191d (patch) | |
tree | d8af36d4d24b7e60126bfbc142c7cba07d6428a8 | |
parent | ffdeaf1b981384455e23e8ad553460daadbd2b7f (diff) | |
download | illumos-joyent-af1789055445dd0a96fd357b570f975640eb191d.tar.gz |
OS-3475 lxbrand 64bit many ltp tests fail with 'rmobj(/tmp/ltp-aGmcd9wj7J/dupE93cbG) failed: remove(/tmp/ltp-aGmcd9wj7J/dupE93cbG) failed; errno=22'
-rw-r--r-- | usr/src/lib/brand/lx/lx_brand/common/file.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/usr/src/lib/brand/lx/lx_brand/common/file.c b/usr/src/lib/brand/lx/lx_brand/common/file.c index 0beb942395..56201035ff 100644 --- a/usr/src/lib/brand/lx/lx_brand/common/file.c +++ b/usr/src/lib/brand/lx/lx_brand/common/file.c @@ -461,10 +461,33 @@ long lx_rmdir(uintptr_t p1) { int r; + char *nm = (char *)p1; - r = rmdir((char *)p1); - if (r < 0) - return ((errno == EEXIST) ? -ENOTEMPTY : -errno); + r = rmdir(nm); + if (r < 0) { + int terr = errno; + + /* + * On both Illumos and Linux rmdir returns EINVAL if the last + * component of the path is '.', but on Illumos we also return + * this errno if we're trying to remove the CWD. Unfortunately, + * at least the LTP test suite assumes that it can rmdir the + * CWD, so we need handle this. We try to get out of the + * directory we're trying to remove. + */ + if (terr == EINVAL) { + int l; + + l = strlen(nm); + if (l >= 2 && !(nm[l - 2] == '/' && nm[l - 1] == '.')) { + if (chdir("..") == 0 && rmdir(nm) == 0) { + return (0); + } + } + } + + return ((terr == EEXIST) ? -ENOTEMPTY : -terr); + } return (0); } |