From a9eee2c50ad67e91c786e6bfaf3cab22daba4b67 Mon Sep 17 00:00:00 2001 From: Gianluca Guida Date: Tue, 31 May 2005 02:58:48 +0000 Subject: node_unlink_file bugfix --- ChangeLog | 14 ++++++++++---- node.c | 21 ++++++++++++++++++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf464e6..00d5d05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,16 +1,22 @@ +2005-05-31 Gianluca Guida + + * node.c (node_unlink_file): Use lookup to figure out whether a file + exists or not, or it will fail on read-only filesystems. + Reported by Ben Asselstine. + 2005-05-30 Gianluca Guida * AUTHORS: Added myself in the list. * README: Added sections "Introduction" and "Stowing Feature". * options.c (argp_program_bug_address): Changed address. - * lib.c (for_each_subdir): When call to stat() fails continue free - "name" and continue the loop, instead of returning error. Return 0 - at the end of the loop. + * lib.c (for_each_subdir): When call to stat() fails free "name" + and continue the loop, instead of returning error. Return 0 at the + end of the loop. (for_each_subdir_priv): Likewise. * stow.c (_stow_registermatchingdirs): Don't return error when - patternlist_match return false. Free filepath before returning + patternlist_match returns false. Free filepath before returning error when ulfs_register fails. * ulfs.c (ulfs_register): Removed bogus fprintf. diff --git a/node.c b/node.c index a3d74ea..cf9a8b4 100644 --- a/node.c +++ b/node.c @@ -229,6 +229,8 @@ node_dir_create (node_t *dir, char *name, mode_t mode) error_t node_unlink_file (node_t *dir, char *name) { + mach_port_t p; + struct stat stat; error_t err = 0; int removed = 0; @@ -243,6 +245,21 @@ node_unlink_file (node_t *dir, char *name) if (!port_valid (node_ulfs->port)) continue; + err = file_lookup (node_ulfs->port, name, + O_NOTRANS, O_NOTRANS, + 0, &p, &stat); + + port_dealloc (p); + + if (err == ENOENT) + { + err = 0; + continue; + } + + if (err) + break; + err = dir_unlink (node_ulfs->port, name); if ((err) && (err != ENOENT)) break; @@ -250,11 +267,9 @@ node_unlink_file (node_t *dir, char *name) if (!err) removed++; - /* Ignore ENOENT. */ - err = 0; } - if (!removed) + if ((!err) && (!removed)) err = ENOENT; return err; -- cgit v1.2.3