aboutsummaryrefslogtreecommitdiffstats
path: root/guts/rmdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'guts/rmdir.c')
-rw-r--r--guts/rmdir.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/guts/rmdir.c b/guts/rmdir.c
index 811ce87..f3cd9e4 100644
--- a/guts/rmdir.c
+++ b/guts/rmdir.c
@@ -6,6 +6,7 @@
* wrap_rmdir(const char *path) {
* int rc = -1;
*/
+ pseudo_msg_t *old_file;
struct stat64 buf;
int save_errno;
@@ -13,13 +14,24 @@
if (rc == -1) {
return rc;
}
+ old_file = pseudo_client_op(OP_UNLINK, 0, -1, -1, path, &buf);
rc = real_rmdir(path);
- save_errno = errno;
- if (rc != -1) {
- pseudo_client_op(OP_UNLINK, 0, -1, -1, path, &buf);
+ if (rc == -1) {
+ save_errno = errno;
+ if (old_file && old_file->result == RESULT_SUCCEED) {
+ pseudo_debug(1, "rmdir failed, trying to relink...\n");
+ buf.st_uid = old_file->uid;
+ buf.st_gid = old_file->uid;
+ buf.st_mode = old_file->mode;
+ buf.st_dev = old_file->dev;
+ buf.st_ino = old_file->ino;
+ pseudo_client_op(OP_LINK, 0, -1, -1, path, &buf);
+ } else {
+ pseudo_debug(1, "rmdir failed, but found no database entry, ignoring.\n");
+ }
+ errno = save_errno;
}
- errno = save_errno;
/* return rc;
* }
*/