diff options
author | Gianluca Guida <glguida@gmail.com> | 2005-05-31 02:58:48 +0000 |
---|---|---|
committer | Gianluca Guida <glguida@gmail.com> | 2005-05-31 02:58:48 +0000 |
commit | a9eee2c50ad67e91c786e6bfaf3cab22daba4b67 (patch) | |
tree | 207944253bbfa965234c88cdf16c824855139e3a | |
parent | 5030481050eeccb65643d849d6fb06d005f47c93 (diff) |
node_unlink_file bugfix
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | node.c | 21 |
2 files changed, 28 insertions, 7 deletions
@@ -1,16 +1,22 @@ +2005-05-31 Gianluca Guida <glguida@gmail.com> + + * 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 <glguida@gmail.com> * 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. @@ -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; |