/*
- * Copyright (c) 2006-2017 Apple Inc. All rights reserved.
+ * Copyright (c) 2006-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <kern/task.h>
#include <kern/sched_prim.h>
+#if CONFIG_NFS4
int
nfs4_access_rpc(nfsnode_t np, u_int32_t *access, int rpcflags, vfs_context_t ctx)
{
}
return error;
}
+#endif /* CONFIG_NFS4 */
/*
* Wait for any pending recovery to complete.
int
nfs_mount_state_wait_for_recovery(struct nfsmount *nmp)
{
- struct timespec ts = { 1, 0 };
+ struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 };
int error = 0, slpflag = NMFLAG(nmp, INTR) ? PCATCH : 0;
lck_mtx_lock(&nmp->nm_lock);
int
nfs_mount_state_in_use_start(struct nfsmount *nmp, thread_t thd)
{
- struct timespec ts = { 1, 0 };
+ struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 };
int error = 0, slpflag = (NMFLAG(nmp, INTR) && thd) ? PCATCH : 0;
if (nfs_mount_gone(nmp)) {
nfs_open_state_set_busy(nfsnode_t np, thread_t thd)
{
struct nfsmount *nmp;
- struct timespec ts = {2, 0};
+ struct timespec ts = { .tv_sec = 2, .tv_nsec = 0 };
int error = 0, slpflag;
nmp = NFSTONMP(np);
nfs_open_owner_set_busy(struct nfs_open_owner *noop, thread_t thd)
{
struct nfsmount *nmp;
- struct timespec ts = {2, 0};
+ struct timespec ts = { .tv_sec = 2, .tv_nsec = 0 };
int error = 0, slpflag;
nmp = noop->noo_mount;
nfs_open_file_set_busy(struct nfs_open_file *nofp, thread_t thd)
{
struct nfsmount *nmp;
- struct timespec ts = {2, 0};
+ struct timespec ts = { .tv_sec = 2, .tv_nsec = 0 };
int error = 0, slpflag;
nmp = nofp->nof_owner->noo_mount;
lck_mtx_unlock(&nofp->nof_lock);
}
-
+#if CONFIG_NFS4
/*
* Get the current (delegation, lock, open, default) stateid for this node.
* If node has a delegation, use that stateid.
}
return error;
}
+#endif /* CONFIG_NFS4 */
int
nfs_vnop_mmap(
NP(np, "nfs_vnop_mmap: no open file for owner, error %d, %d", error, kauth_cred_getuid(noop->noo_cred));
error = EPERM;
}
+#if CONFIG_NFS4
if (!error && (nofp->nof_flags & NFS_OPEN_FILE_REOPEN)) {
nfs_mount_state_in_use_end(nmp, 0);
error = nfs4_reopen(nofp, NULL);
goto restart;
}
}
+#endif
if (!error) {
error = nfs_open_file_set_busy(nofp, NULL);
}
/* NFS v2/v3 opens are always allowed - so just add it. */
nfs_open_file_add_open(nofp, NFS_OPEN_SHARE_ACCESS_READ, NFS_OPEN_SHARE_DENY_NONE, 0);
error = 0;
- } else {
+ }
+#if CONFIG_NFS4
+ else {
error = nfs4_open(np, nofp, NFS_OPEN_SHARE_ACCESS_READ, NFS_OPEN_SHARE_DENY_NONE, ctx);
}
+#endif
if (!error) {
nofp->nof_flags |= NFS_OPEN_FILE_NEEDCLOSE;
}
continue;
}
lck_mtx_unlock(&np->n_openlock);
+#if CONFIG_NFS4
if (nofp->nof_flags & NFS_OPEN_FILE_REOPEN) {
nfs_mount_state_in_use_end(nmp, 0);
error = nfs4_reopen(nofp, NULL);
goto loop;
}
}
+#endif
if (!error) {
error = nfs_open_file_set_busy(nofp, NULL);
}
nfs_lock_owner_set_busy(struct nfs_lock_owner *nlop, thread_t thd)
{
struct nfsmount *nmp;
- struct timespec ts = {2, 0};
+ struct timespec ts = { .tv_sec = 2, .tv_nsec = 0 };
int error = 0, slpflag;
nmp = nlop->nlo_open_owner->noo_mount;
return 1;
}
+#if CONFIG_NFS4
/*
* Send an NFSv4 LOCK RPC to the server.
*/
nfsm_chain_cleanup(&nmrep);
return error;
}
-
+#endif /* CONFIG_NFS4 */
/*
* Check for any conflicts with the given lock.
struct nfs_file_lock *newnflp, *nflp, *nflp2 = NULL, *nextnflp, *flocknflp = NULL;
struct nfs_file_lock *coalnflp;
int error = 0, error2, willsplit = 0, delay, slpflag, busy = 0, inuse = 0, restart, inqueue = 0;
- struct timespec ts = {1, 0};
+ struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 };
nmp = NFSTONMP(np);
if (nfs_mount_gone(nmp)) {
inuse = 0;
goto error_out;
}
+#if CONFIG_NFS4
if (nofp->nof_flags & NFS_OPEN_FILE_REOPEN) {
nfs_mount_state_in_use_end(nmp, 0);
inuse = 0;
}
goto restart;
}
+#endif
lck_mtx_lock(&np->n_openlock);
if (!inqueue) {
busy = 1;
delay = 0;
do {
+#if CONFIG_NFS4
/* do we have a delegation? (that we're not returning?) */
if ((np->n_openflags & N_DELEG_MASK) && !(np->n_openflags & N_DELEG_RETURN)) {
if (np->n_openflags & N_DELEG_WRITE) {
}
}
}
+#endif
if (np->n_flag & NREVOKE) {
error = EIO;
}
int
nfs_advlock_unlock(
nfsnode_t np,
- struct nfs_open_file *nofp,
+ struct nfs_open_file *nofp
+#if !CONFIG_NFS4
+ __unused
+#endif
+ ,
struct nfs_lock_owner *nlop,
uint64_t start,
uint64_t end,
if ((error = nfs_mount_state_in_use_start(nmp, NULL))) {
return error;
}
+#if CONFIG_NFS4
if (nofp->nof_flags & NFS_OPEN_FILE_REOPEN) {
nfs_mount_state_in_use_end(nmp, 0);
error = nfs4_reopen(nofp, NULL);
}
goto restart;
}
+#endif
if ((error = nfs_open_state_set_busy(np, NULL))) {
nfs_mount_state_in_use_end(nmp, error);
return error;
goto out;
}
/* find the open file */
+#if CONFIG_NFS4
restart:
+#endif
error = nfs_open_file_find(np, noop, &nofp, 0, 0, 0);
if (error) {
error = EBADF;
NP(np, "nfs_vnop_advlock: LOST %d", kauth_cred_getuid(nofp->nof_owner->noo_cred));
error = EIO;
}
+#if CONFIG_NFS4
if (!error && (nofp->nof_flags & NFS_OPEN_FILE_REOPEN)) {
error = nfs4_reopen(nofp, ((op == F_UNLCK) ? NULL : vfs_context_thread(ctx)));
nofp = NULL;
goto restart;
}
}
+#endif
if (error) {
NP(np, "nfs_vnop_advlock: no open file %d, %d", error, kauth_cred_getuid(noop->noo_cred));
goto out;
return nlop ? 1 : 0;
}
+#if CONFIG_NFS4
/*
* Reopen simple (no deny, no locks) open state that was lost.
*/
char smallname[128];
char *filename = NULL;
int error = 0, done = 0, slpflag = NMFLAG(nmp, INTR) ? PCATCH : 0;
- struct timespec ts = { 1, 0 };
+ struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 };
lck_mtx_lock(&nofp->nof_lock);
while (nofp->nof_flags & NFS_OPEN_FILE_REOPENING) {
struct nfs_sillyrename *nsp = np->n_sillyrename;
dvp = NFSTOV(nsp->nsr_dnp);
if ((error = vnode_get(dvp))) {
+ dvp = NULLVP;
nfs_node_unlock(np);
goto out;
}
struct nfs_sillyrename *nsp = np->n_sillyrename;
dvp = NFSTOV(nsp->nsr_dnp);
if ((error = vnode_get(dvp))) {
+ dvp = NULLVP;
nfs_node_unlock(np);
goto out;
}
return error;
}
+#endif /* CONFIG_NFS4*/
/*
* Release all open state for the given node.
nofp->nof_flags |= NFS_OPEN_FILE_LOST;
lck_mtx_unlock(&nofp->nof_lock);
+#if CONFIG_NFS4
if (!force && nmp && (nmp->nm_vers >= NFS_VER4)) {
nfs4_close_rpc(np, nofp, NULL, nofp->nof_owner->noo_cred, R_RECOVER);
}
+#endif
}
lck_mtx_unlock(&np->n_openlock);
}
}
+#if CONFIG_NFS4
/*
* Claim the delegated open combinations that each of this node's open files hold.
*/
nfsm_chain_cleanup(&nmrep);
return error;
}
-
+#endif /* CONFIG_NFS4 */
/*
* NFS read call.
NP(np, "nfs_vnop_read: LOST %d", kauth_cred_getuid(noop->noo_cred));
error = EIO;
}
+#if CONFIG_NFS4
if (!error && (nofp->nof_flags & NFS_OPEN_FILE_REOPEN)) {
error = nfs4_reopen(nofp, vfs_context_thread(ctx));
nofp = NULL;
goto restart;
}
}
+#endif
if (error) {
nfs_open_owner_rele(noop);
return error;
if (nmp->nm_vers < NFS_VER4) {
/* NFS v2/v3 opens are always allowed - so just add it. */
nfs_open_file_add_open(nofp, NFS_OPEN_SHARE_ACCESS_READ, NFS_OPEN_SHARE_DENY_NONE, 0);
- } else {
+ }
+#if CONFIG_NFS4
+ else {
error = nfs4_open(np, nofp, NFS_OPEN_SHARE_ACCESS_READ, NFS_OPEN_SHARE_DENY_NONE, ctx);
}
+#endif
if (!error) {
nofp->nof_flags |= NFS_OPEN_FILE_NEEDCLOSE;
}
return nfs_bioread(VTONFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_context);
}
+#if CONFIG_NFS4
/*
* Note: the NFSv4 CREATE RPC is for everything EXCEPT regular files.
* Files are created using the NFSv4 OPEN RPC. So we must open the
}
#endif
+#endif /* CONFIG_NFS4 */