diff options
author | Michael I. Bushnell <mib@gnu.org> | 1996-03-20 20:50:37 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1996-03-20 20:50:37 +0000 |
commit | 049354a66a11b9213a3e4189606ff1d99f039431 (patch) | |
tree | 21cbdf6462b9b934e867c4997ef4962b0ce0c561 /libdiskfs | |
parent | cf019b1187b412eb18cb91af5c42952d9e2166a4 (diff) |
Initial revision
Diffstat (limited to 'libdiskfs')
-rw-r--r-- | libdiskfs/dirremove.c | 45 | ||||
-rw-r--r-- | libdiskfs/lookup.c | 78 |
2 files changed, 123 insertions, 0 deletions
diff --git a/libdiskfs/dirremove.c b/libdiskfs/dirremove.c new file mode 100644 index 00000000..4032f0a7 --- /dev/null +++ b/libdiskfs/dirremove.c @@ -0,0 +1,45 @@ +/* Wrapper for diskfs_dirremove_hard + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include "priv.h" + +/* This will only be called after a successful call to diskfs_lookup + of type REMOVE; this call should remove the name found from the + directory DS. DP has been locked continuously since the call to + diskfs_lookup and DS is as that call set it. This routine should + call diskfs_notice_dirchange if DP->dirmod_reqs is nonzero. This + function is a wrapper for diskfs_dirremove_hard. The entry being + removed has name NAME and refers to NP. */ +error_t +diskfs_dirremove (struct node *dp, + struct node *np, + char *name, + struct dirstat *ds) +{ + error_t err; + + diskfs_purge_cache (dp, np); + + err = diskfs_dirremove_hard (dp, ds); + if (!err && dp->dirmod_reqs) + diskfs_notice_dirchange (dp, DIR_CHANGED_UNLINK, name); + return err; +} + diff --git a/libdiskfs/lookup.c b/libdiskfs/lookup.c new file mode 100644 index 00000000..59100cef --- /dev/null +++ b/libdiskfs/lookup.c @@ -0,0 +1,78 @@ +/* Wrapper for diskfs_lookup_hard + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include "priv.h" + +/* Lookup in directory DP (which is locked) the name NAME. TYPE will + either be LOOKUP, CREATE, RENAME, or REMOVE. CRED identifies the + user making the call. + + If the name is found, return zero, and (if NP is nonzero) set *NP + to point to the node for it, locked. If the name is not found, + return ENOENT, and (if NP is nonzero) set *NP to zero. If NP is + zero, then the node found must not be locked, even transitorily. + Lookups for REMOVE and RENAME (which must often check permissions + on the node being found) will always set NP. + + If DS is nonzero then: + For LOOKUP: set *DS to be ignored by diskfs_drop_dirstat. + For CREATE: on success, set *DS to be ignored by diskfs_drop_dirstat. + on failure, set *DS for a future call to diskfs_direnter. + For RENAME: on success, set *DS for a future call to diskfs_dirrewrite. + on failure, set *DS for a future call to diskfs_direnter. + For REMOVE: on success, set *DS for a future call to diskfs_dirremove. + on failure, set *DS to be ignored by diskfs_drop_dirstat. + The caller of this function guarantees that if DS is nonzero, then + either the appropriate call listed above or diskfs_drop_dirstat will + be called with DS before the directory DP is unlocked, and guarantees + that no lookup calls will be made on this directory between this + lookup and the use (or descruction) of *DS. + + If you use the library's versions of diskfs_rename_dir, + diskfs_clear_directory, and diskfs_init_dir, then lookups for `..' + might have the flag SPEC_DOTDOT or'd in. This has the following special + meaning: + For LOOKUP: DP should be unlocked and its reference dropped before + returning. + For RENAME and REMOVE: The node being found (*NP) is already held + locked, so don't lock it or add a reference to it. + (SPEC_DOTDOT will not be given with CREATE.) + + Return ENOTDIR if DP is not a directory. + Return EACCES if CRED isn't allowed to search DP. + Return EACCES if completing the operation will require writing + the directory and diskfs_checkdirmod won't allow the modification. + Return ENOENT if NAME isn't in the directory. + Return EAGAIN if NAME refers to the `..' of this filesystem's root. + Return EIO if appropriate. + + This function is a wrapper for diskfs_lookup_hard. +*/ +error_t +diskfs_lookup (struct node *dp, + char *name, + enum lookup_type type, + struct node **np, + struct dirstat *ds, + struct protid *cred) +{ + return diskfs_lookup_hard (dp, name, type, np, ds, cred); +} + |