/*
- * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* FreeBSD-Id: nfs_node.c,v 1.22 1997/10/28 14:06:20 bde Exp $
*/
+#include <nfs/nfs_conf.h>
+#if CONFIG_NFS_CLIENT
#include <sys/param.h>
#include <sys/kernel.h>
cmp = nfs_case_insensitive(mp) ? strncasecmp : strncmp;
+ if (vp->v_name && (size_t)cnp->cn_namelen != strnlen(vp->v_name, MAXPATHLEN)) {
+ update_flags |= VNODE_UPDATE_NAME;
+ }
if (vp->v_name && cnp->cn_namelen && (*cmp)(cnp->cn_nameptr, vp->v_name, cnp->cn_namelen)) {
update_flags |= VNODE_UPDATE_NAME;
}
vfsp.vnfs_str = "nfs";
vfsp.vnfs_dvp = dnp ? NFSTOV(dnp) : NULL;
vfsp.vnfs_fsnode = np;
+#if CONFIG_NFS4
if (nfsvers == NFS_VER4) {
#if FIFO
if (nvap->nva_type == VFIFO) {
} else {
vfsp.vnfs_vops = nfsv4_vnodeop_p;
}
- } else {
+ } else
+#endif /* CONFIG_NFS4 */
+ {
#if FIFO
if (nvap->nva_type == VFIFO) {
vfsp.vnfs_vops = fifo_nfsv2nodeop_p;
}
#if CONFIG_TRIGGERS
- if ((nfsvers >= NFS_VER4) && (nvap->nva_type == VDIR) && (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER)) {
+ if (((nfsvers >= NFS_VER4)
+ )
+ && (nvap->nva_type == VDIR) && (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER)
+ && !(flags & NG_MARKROOT)) {
struct vnode_trigger_param vtp;
bzero(&vtp, sizeof(vtp));
bcopy(&vfsp, &vtp.vnt_params, sizeof(vfsp));
vtp.vnt_resolve_func = nfs_mirror_mount_trigger_resolve;
vtp.vnt_unresolve_func = nfs_mirror_mount_trigger_unresolve;
vtp.vnt_rearm_func = nfs_mirror_mount_trigger_rearm;
- vtp.vnt_flags = VNT_AUTO_REARM;
+ vtp.vnt_flags = VNT_AUTO_REARM | VNT_KERN_RESOLVE;
error = vnode_create(VNCREATE_TRIGGER, VNCREATE_TRIGGER_SIZE, &vtp, &np->n_vnode);
} else
#endif
* node has gone inactive without being open, we need to
* clean up (close) the open done in the create.
*/
+#if CONFIG_NFS4
if ((nofp->nof_flags & NFS_OPEN_FILE_CREATE) && nofp->nof_creator && !force) {
if (nofp->nof_flags & NFS_OPEN_FILE_REOPEN) {
lck_mtx_unlock(&np->n_openlock);
}
goto restart;
}
+#endif
if (nofp->nof_flags & NFS_OPEN_FILE_NEEDCLOSE) {
/*
* If the file is marked as needing reopen, but this was the only
if (inuse) {
nfs_mount_state_in_use_end(nmp, 0);
}
+#if CONFIG_NFS4
if (!nfs4_reopen(nofp, NULL)) {
goto restart;
}
+#endif
}
error = nfs_close(np, nofp, NFS_OPEN_SHARE_ACCESS_READ, NFS_OPEN_SHARE_DENY_NONE, ctx);
if (error) {
{
vnode_t vp = ap->a_vp;
nfsnode_t np = VTONFS(vp);
- vfs_context_t ctx = ap->a_context;
struct nfs_open_file *nofp, *nextnofp;
struct nfs_file_lock *nflp, *nextnflp;
struct nfs_lock_owner *nlop, *nextnlop;
FSDBG_TOP(265, vp, np, np->n_flag, 0);
force = (!mp || vfs_isforce(mp) || nfs_mount_gone(nmp));
+
/* There shouldn't be any open or lock state at this point */
lck_mtx_lock(&np->n_openlock);
+#if CONFIG_NFS4
if (nmp && (nmp->nm_vers >= NFS_VER4)) {
/* need to drop a delegation */
if (np->n_dreturn.tqe_next != NFSNOLIST) {
np->n_attrdirfh = NULL;
}
}
+#endif
/* clean up file locks */
TAILQ_FOREACH_SAFE(nflp, &np->n_locks, nfl_link, nextnflp) {
nofp->nof_r_drw, nofp->nof_d_r_drw,
nofp->nof_w_drw, nofp->nof_d_w_drw,
nofp->nof_rw_drw, nofp->nof_d_rw_drw);
+#if CONFIG_NFS4
/* try sending a close RPC if it wasn't delegated */
if (nofp->nof_r || nofp->nof_w || nofp->nof_rw ||
nofp->nof_r_dw || nofp->nof_w_dw || nofp->nof_rw_dw ||
nofp->nof_r_drw || nofp->nof_w_drw || nofp->nof_rw_drw) {
nfs4_close_rpc(np, nofp, NULL, nofp->nof_owner->noo_cred, R_RECOVER);
}
+#endif
}
}
TAILQ_REMOVE(&np->n_opens, nofp, nof_link);
/* then remove this node from the monitored node list. */
lck_mtx_lock(&nmp->nm_lock);
while (np->n_mflag & NMMONSCANINPROG) {
- struct timespec ts = { 1, 0 };
+ struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 };
np->n_mflag |= NMMONSCANWANT;
msleep(&np->n_mflag, &nmp->nm_lock, PZERO - 1, "nfswaitmonscan", &ts);
}
int
nfs_node_set_busy(nfsnode_t np, thread_t thd)
{
- struct timespec ts = { 2, 0 };
+ struct timespec ts = { .tv_sec = 2, .tv_nsec = 0 };
int error;
if ((error = nfs_node_lock(np))) {
return i <= nfsnodehash;
}
+
+#endif /* CONFIG_NFS_CLIENT */