Lines Matching +full:test2 +full:. +full:zeros

5  *	The Regents of the University of California.  All rights reserved.
8 * Rick Macklem at The University of Guelph.
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
20 * without specific prior written permission.
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * SUCH DAMAGE.
36 #include <sys/cdefs.h>
39 * the nfs op functions. They do things like create the rpc header and
40 * copy data between mbuf chains and uio lists.
42 #include "opt_inet.h"
43 #include "opt_inet6.h"
45 #include <fs/nfs/nfsport.h>
46 #include <fs/nfsclient/nfsmount.h>
48 #include <sys/extattr.h>
50 #include <security/mac/mac_framework.h>
52 #include <vm/vm_param.h>
115 * non-idempotent Ops.
116 * Define it here, since it is used by both the client and server.
214 * reply. This is used by nfs_reply() to decide whether or not an mbuf
215 * cluster should be allocated. (If a cluster is required by an RPC
217 * efficiently.)
313 * NFS RPCS that have large request message size.
323 * Start building a request. Mostly just put the first file handle in
324 * place.
337 * First, fill in some of the fields of nd.
365 * Get the first mbuf for the request.
375 /* For NFSPROC_NULL, there are no arguments. */
380 * And fill the first file handle into the request.
383 opcnt = nfsv4_opmap[procnum].opcnt +
384 nfsv4_opflag[nfsv4_opmap[procnum].op].needscfh;
386 opcnt += nfsv4_opflag[nfsv4_opmap[procnum].op].needsseq;
390 * Sequence Op.
398 * Write/Commit.
405 (void) nfsm_strtom(nd, nfsv4_opmap[procnum].tag,
406 nfsv4_opmap[procnum].taglen);
418 nfsv4_opflag[nfsv4_opmap[procnum].op].needsseq > 0) {
419 if (nfsv4_opflag[nfsv4_opmap[procnum].op].loopbadsess >
428 * slots. If the caller does not want this
430 * be passed in as NULL.
438 if (nfsv4_opflag[nfsv4_opmap[procnum].op].needscfh > 0) {
442 if (nfsv4_opflag[nfsv4_opmap[procnum].op].needscfh
449 * attributes, so we can load the name cache.
457 /* For AppendWrite, get the size. */
469 *tl = txdr_unsigned(nfsv4_opmap[procnum].op);
476 NFSINCRGLOBAL(nfsstatsv1.rpccnt[procnum]);
480 * Put a state Id in the mbuf list.
512 * Fill in the setable attributes. The full argument indicates whether
513 * to fill in them all or just mode and time.
583 if (vap->va_atime.tv_sec != VNOVAL) {
596 if (vap->va_mtime.tv_sec != VNOVAL) {
617 NFSISSET_ATTRBIT(&np->n_vattr.na_suppattr,
630 if (vap->va_atime.tv_sec != VNOVAL)
632 if (vap->va_mtime.tv_sec != VNOVAL)
636 * the "vp" argument is for an NFS vnode.
638 if (vap->va_birthtime.tv_sec != VNOVAL && np != NULL &&
639 NFSISSET_ATTRBIT(&np->n_vattr.na_suppattr,
727 * pointed to by returned val.
729 * cases.
792 * Advance the position in the mbuf chain.
794 * here than check for offs > 0 for all calls to nfsm_advance.
795 * If left == -1, it should be calculated here.
806 * as such, a printf is logged.
815 * If left == -1, calculate it here.
822 * Loop around, advancing over the mbuf data.
842 * Copy a string into mbuf(s).
843 * Return the number of bytes output, including XDR overheads.
872 * Loop around copying the string to mbuf(s).
929 * Called once to initialize data structures...
955 * Put a file handle in an mbuf list.
956 * If the size argument == 0, just use the default size.
957 * set_true == 1 if there should be an newnfs_true prepended on the file handle.
958 * Return the number of bytes output, including XDR overhead.
1005 * if they are the same host.
1006 * If there is any doubt, return FALSE.
1008 * don't need to be saved to store "struct in_addr", which is only 4 bytes.
1022 inetaddr->sin_addr.s_addr == haddr->had_inet.s_addr)
1045 * Similar to the above, but takes to NFSSOCKADDR_T args.
1059 addr1->sin_addr.s_addr == addr2->sin_addr.s_addr)
1082 * Dissect a file handle on the client.
1116 * Break down the nfsv4 acl.
1117 * If the aclp == NULL or won't fit in an acl, just discard the acl info.
1132 * what can be supported by R/W/X bits.
1139 * an ACL, but 10240 should be more than sufficient.
1171 * Skip over an NFSv4 ace entry. Just dissect the xdr and discard it.
1189 * Get attribute bits from an mbuf list.
1190 * Returns EBADRPC for a parsing error, 0 otherwise.
1191 * If the clearinvalid flag is set, clear the bits not supported.
1230 * Get operation bits from an mbuf list.
1231 * Returns EBADRPC for a parsing error, 0 otherwise.
1271 * Get the attributes for V4.
1273 * otherwise return the attribute values.
1275 * "struct nfsfsinfo", the file handle and the lease duration.
1277 * and 0 otherwise.
1278 * Returns EBADRPC if it can't be parsed, 0 otherwise.
1321 * Just set default values to some of the important ones.
1328 nap->na_mtime.tv_sec = 0;
1329 nap->na_mtime.tv_nsec = 0;
1330 nap->na_btime.tv_sec = -1;
1331 nap->na_btime.tv_nsec = 0;
1353 fsp->fs_timedelta.tv_sec = 0;
1354 fsp->fs_timedelta.tv_nsec = 1;
1377 * Loop around getting the attributes.
1513 vp->v_mount->mnt_stat.f_fsid.val[0] ||
1515 vp->v_mount->mnt_stat.f_fsid.val[1])
1782 tnfsquad.qval = fxdr_hyper(tl);
1786 if (tquad != tnfsquad.qval)
1790 fsp->fs_maxfilesize = tnfsquad.qval;
1819 * NFS_MAXNAMLEN. If a server actually creates
1821 * get an error back.
1987 * we'll just make sure that's the case.
1993 freenum = min(dqb.dqb_bhardlimit, freenum);
2016 * we'll just make sure that's the case.
2022 freenum = min(dqb.dqb_bsoftlimit, freenum);
2042 * we'll just make sure that's the case.
2048 freenum = dqb.dqb_curblocks;
2181 if ((u_int32_t)fsp->fs_timedelta.tv_sec !=
2183 (u_int32_t)fsp->fs_timedelta.tv_nsec !=
2271 * than enough.
2330 * the unknown attribute data.
2339 * padding.
2355 * Implement sleep locks for newnfs. The nfslock_usecnt allows for a
2356 * shared lock and the NFSXXX_LOCK flag permits an exclusive lock.
2357 * The first argument is a pointer to an nfsv4lock structure.
2358 * The second argument is 1 iff a blocking lock is wanted.
2360 * holds an exclusive lock.
2361 * It returns 1 if the lock was acquired, 0 otherwise.
2364 * lock. (If the caller must have the lock, it simply calls this function in a
2365 * loop until the function returns 1 to indicate the lock was acquired.)
2367 * calling nfsv4_lock(). It was done this way, so nfsv4_lock() could
2368 * be called in a loop.
2371 * NULL.
2382 * someone and then released. If I want the lock, try to acquire it.
2384 * must be zero.
2415 * Release the lock acquired by nfsv4_lock().
2417 * incremented, as well.
2430 * Release a reference cnt.
2444 * Get a reference cnt.
2446 * not wait for threads that want the exclusive lock. If priority needs
2448 * with the 2nd argument == 0 should be done before calling nfsv4_getref().
2450 * return without getting a refcnt for that case.
2461 * Wait for a lock held.
2479 * an exclusive lock is held.
2493 * Test for a lock. Return 1 if locked, 0 otherwise.
2506 * Wake up anyone sleeping, waiting for this lock.
2519 * Copy a string from an mbuf list into a character array.
2521 * 0 otherwise.
2572 * Fill in the attributes as marked by the bitmap (V4).
2601 * First, set the bits that can be filled and get fsinfo.
2605 * If both p and cred are NULL, it is a client side setattr call.
2606 * If both p and cred are not NULL, it is a server side reply call.
2608 * reply call.
2620 * Get the VFS_STATFS(), since some attributes need them.
2636 * so set them to 0. Without this, they will appear
2638 * Solaris10.
2647 * And the NFSv4 ACL...
2678 /* Check to see if Extended Attributes are supported. */
2692 * and get the field for the number of attributes returned.
2699 * Now, loop around filling in the attributes for each bit set.
2735 if (fsinf.fs_properties & NFSV3FSINFO_LINK)
2743 if (fsinf.fs_properties & NFSV3FSINFO_SYMLINK)
2757 *tl++ = txdr_unsigned(mp->mnt_stat.f_fsid.val[0]);
2759 *tl = txdr_unsigned(mp->mnt_stat.f_fsid.val[1]);
2778 * Recommended Attributes. (Only the supported ones.)
2790 if (fsinf.fs_properties & NFSV3FSINFO_CANSETTIME)
2847 if (fsinf.fs_properties & NFSV3FSINFO_HOMOGENEOUS)
2872 *tl = txdr_unsigned(fsinf.fs_rtmax);
2878 *tl = txdr_unsigned(fsinf.fs_wtmax);
2919 * we'll just make sure that's the case.
2925 freenum = min(dqb.dqb_bhardlimit, freenum);
2943 * we'll just make sure that's the case.
2949 freenum = min(dqb.dqb_bsoftlimit, freenum);
2964 * we'll just make sure that's the case.
2970 freenum = dqb.dqb_curblocks;
3053 temptime.tv_sec = 0;
3054 temptime.tv_nsec = 1000000000 / hz;
3108 *tl++ = txdr_unsigned(1); /* One entry. */
3139 * there is no umask to handle here. If FreeBSD
3141 * this could change.
3175 * Calculate the files available attribute value.
3188 * Check quota and use min(quota, f_ffree).
3194 * for FreeBSD. I do not know if doing this is
3195 * useful, so I will just leave the code here.
3201 * we'll just make sure that's the case.
3207 freenum = min(dqb.dqb_isoftlimit-dqb.dqb_curinodes,
3215 * Put the attribute bits onto an mbuf list.
3216 * Return the number of bytes of output generated.
3236 * Put the operation bits onto an mbuf list.
3237 * Return the number of bytes of output generated.
3257 * Convert a uid to a string.
3258 * If the lookup fails, just output the digits.
3280 * Always map nfsrv_defaultuid to "nobody".
3309 * in it, append @domainname to it.
3355 * No match, just return a string of digits.
3376 * Get a credential for the uid with the server's group list.
3378 * logging a warning message.
3421 * Convert a string to a uid.
3423 * return 0.
3426 * a number.
3444 /* If a string of digits and an AUTH_SYS mount, just convert it. */
3448 /* A numeric string. */
3458 * Look for an '@'.
3471 * the name with dns stripped off.
3473 * since RFC8881 defines this string as a DNS domain name.
3484 * Check for the special case of "nobody".
3527 * Convert a gid to a string.
3549 * Always map nfsrv_defaultgid to "nogroup".
3578 * in it, append @domainname to it.
3624 * No match, just return a string of digits.
3645 * Convert a string to a gid.
3647 * return 0.
3650 * a number.
3668 /* If a string of digits and an AUTH_SYS mount, just convert it. */
3672 /* A numeric string. */
3682 * Look for an '@'.
3695 * name with the dns stripped off.
3706 * Check for the special case of "nogroup".
3749 * Set the port for the nfsuserd.
3772 * Set up the socket record and connect.
3774 * process/thread/core will use a bogus old value. This could only
3776 * broken.
3795 ad->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
3833 * Delete the nfsuserd port.
3845 /* Wait for all upcalls to complete. */
3851 free(NFSD_VNET(nfsrv_nfsuserdsock).nr_nam, M_SONAME);
3859 * name<-->id cache.
3860 * Returns 0 upon success, non-zero otherwise.
3880 * can wait until no upcalls are in progress.
3922 * kernel user/group name list(s) for the V4 owner and ownergroup attributes.
3952 * lists. All mutexes for both lists must be locked,
3954 * ones, to avoid a LOR.
3957 mtx_lock(&NFSD_VNET(nfsusernamehash)[i].mtx);
3959 mtx_lock(&NFSD_VNET(nfsuserhash)[i].mtx);
3962 &NFSD_VNET(nfsuserhash)[i].lughead, lug_numhash, nusrp)
3965 mtx_unlock(&NFSD_VNET(nfsuserhash)[i].mtx);
3967 mtx_unlock(&NFSD_VNET(nfsusernamehash)[i].mtx);
3969 mtx_lock(&NFSD_VNET(nfsgroupnamehash)[i].mtx);
3971 mtx_lock(&NFSD_VNET(nfsgrouphash)[i].mtx);
3974 &NFSD_VNET(nfsgrouphash)[i].lughead, lug_numhash,
3978 mtx_unlock(&NFSD_VNET(nfsgrouphash)[i].mtx);
3980 mtx_unlock(&NFSD_VNET(nfsgroupnamehash)[i].mtx);
3985 /* Allocate the hash tables. */
3990 mtx_init(&NFSD_VNET(nfsuserhash)[i].mtx, "nfsuidhash",
3996 mtx_init(&NFSD_VNET(nfsusernamehash)[i].mtx,
4003 mtx_init(&NFSD_VNET(nfsgrouphash)[i].mtx, "nfsgidhash",
4009 mtx_init(&NFSD_VNET(nfsgroupnamehash)[i].mtx,
4012 /* (Re)initialize the list heads. */
4014 TAILQ_INIT(&NFSD_VNET(nfsuserhash)[i].lughead);
4016 TAILQ_INIT(&NFSD_VNET(nfsusernamehash)[i].lughead);
4018 TAILQ_INIT(&NFSD_VNET(nfsgrouphash)[i].lughead);
4020 TAILQ_INIT(&NFSD_VNET(nfsgroupnamehash)[i].lughead);
4023 * Put name in "DNS" string.
4037 * manipulation of the lists.
4052 * but using the group list provided.
4076 * by uid[0]->[nfsrv_lughashsize - 1], with the same for group.
4079 * locked. hp_name != NULL and hp_idnum != NULL indicates that
4080 * the respective one mutex is locked.
4086 * Delete old entries, as required.
4089 /* Must lock all username hash lists first, to avoid a LOR. */
4091 mtx_lock(&NFSD_VNET(nfsusernamehash)[i].mtx);
4118 /* Must lock all groupname hash lists first, to avoid a LOR. */
4120 mtx_lock(&NFSD_VNET(nfsgroupnamehash)[i].mtx);
4149 * Now, we can add the new one.
4180 * Once per second, allow one thread to trim the cache.
4186 * can be locked and any LOR is avoided.
4201 mtx_lock(&NFSD_VNET(nfsusernamehash)[i].mtx);
4207 mtx_lock(&NFSD_VNET(nfsuserhash)[i].mtx);
4211 &NFSD_VNET(nfsuserhash)[i].lughead, lug_numhash,
4219 * algorithm. This code deletes the least
4220 * recently used entry on each hash list.
4224 usrp = TAILQ_FIRST(&NFSD_VNET(nfsuserhash)[i].lughead);
4231 mtx_lock(&NFSD_VNET(nfsgroupnamehash)[i].mtx);
4237 mtx_lock(&NFSD_VNET(nfsgrouphash)[i].mtx);
4241 &NFSD_VNET(nfsgrouphash)[i].lughead, lug_numhash,
4249 * algorithm. This code deletes the least
4250 * recently user entry on each hash list.
4254 usrp = TAILQ_FIRST(&NFSD_VNET(nfsgrouphash)[i].lughead);
4263 /* Now, unlock all locked mutexes. */
4270 mtx_unlock(&NFSD_VNET(nfsuserhash)[i].mtx);
4273 mtx_unlock(&NFSD_VNET(nfsusernamehash)[i].mtx);
4276 mtx_unlock(&NFSD_VNET(nfsgrouphash)[i].mtx);
4279 mtx_unlock(&NFSD_VNET(nfsgroupnamehash)[i].mtx);
4286 * Remove a user/group name element.
4315 * Free up all the allocations related to the name<-->id cache.
4317 * running, since it doesn't do any locking.
4318 * This function is meant to be called when a vnet jail is destroyed.
4351 mtx_destroy(&NFSD_VNET(nfsuserhash)[i].mtx);
4352 mtx_destroy(&NFSD_VNET(nfsusernamehash)[i].mtx);
4353 mtx_destroy(&NFSD_VNET(nfsgroupnamehash)[i].mtx);
4354 mtx_destroy(&NFSD_VNET(nfsgrouphash)[i].mtx);
4364 * This function scans a byte string and checks for UTF-8 compliance.
4365 * It returns 0 if it conforms and NFSERR_INVAL if not.
4382 * shift - lower order bits of range (ie. "val >> shift" should
4432 * Parse the xdr for an NFSv4 FsLocations attribute. Return two malloc'd
4434 * locations. The list is in the same format as is found in nfr_refs.
4436 * form <server>:<rootpath>. For example
4437 * "nfsv4-test:/sub2,nfsv4-test2:/user/mnt,nfsv4-test2:/user/mnt2"
4439 * and an empty server list.
4441 * number of xdr bytes parsed in sump.
4463 * and 0 length server list.
4494 * Now, loop through the location list and make up the srvlist.
4510 * Handle the first server by putting it in the srvstr.
4532 * Yuck, put them in an slist and process them later.
4551 * Finally, we can get the path.
4597 * Make the malloc'd space large enough. This is a pain, but the xdr
4598 * doesn't set an upper bound on the side, so...
4618 * Initialize the reply header data structures.
4634 * If this is a big reply, use a cluster.
4655 * Lock a socket against others.
4656 * Currently used to serialize connect/disconnect attempts.
4666 ts.tv_sec = 0;
4667 ts.tv_nsec = 0;
4677 * Unlock the stream socket for others.
4741 * The shortest address is 11chars and the longest is < 64.
4747 /* Find the port# at the end and extract that. */
4751 /* Count back two '.'s from end to get port# field. */
4753 if (*cp == '.') {
4762 * The NFSv4 port# is appended as .N.N, where N is
4764 * address. Cheat and use inet_aton(), which will
4766 * order 8bits over to convert it to the port#.
4770 portnum = ntohl(saddr.s_addr);
4810 * Handle an NFSv4.1 Sequence request for the session.
4811 * If reply != NULL, use it to return the cached reply, as required.
4813 * server gets a cached reply via the nfsv4_seqsess_cacherep() call.
4827 if (seqid == slots[slotid].nfssl_seq) {
4828 /* A retry. */
4829 if (slots[slotid].nfssl_inprog != 0)
4831 else if (slots[slotid].nfssl_reply != NULL) {
4833 m = m_copym(slots[slotid].nfssl_reply, 0,
4838 *reply = slots[slotid].nfssl_reply;
4839 slots[slotid].nfssl_reply = NULL;
4842 slots[slotid].nfssl_inprog = 1;
4845 /* No reply cached, so just do it. */
4846 slots[slotid].nfssl_inprog = 1;
4847 } else if ((slots[slotid].nfssl_seq + 1) == seqid) {
4848 if (slots[slotid].nfssl_reply != NULL)
4849 m_freem(slots[slotid].nfssl_reply);
4850 slots[slotid].nfssl_reply = NULL;
4851 slots[slotid].nfssl_inprog = 1;
4852 slots[slotid].nfssl_seq++;
4859 * Cache this reply for the slot.
4861 * NFSERR_REPLYFROMCACHE. The client never sets repstat to this value.
4870 if (slots[slotid].nfssl_reply != NULL) {
4873 * succeed.
4875 m = m_copym(slots[slotid].nfssl_reply, 0, M_COPYALL,
4883 * be ok.
4885 *rep = slots[slotid].nfssl_reply;
4886 slots[slotid].nfssl_reply = NULL;
4891 if (slots[slotid].nfssl_reply != NULL)
4892 m_freem(slots[slotid].nfssl_reply);
4893 slots[slotid].nfssl_reply = *rep;
4895 slots[slotid].nfssl_inprog = 0;
4899 * Generate the xdr for an NFSv4.1 Sequence Operation.
4913 /* If all slots are bad, Destroy the session. */
4922 /* Build the Sequence arguments. */
4941 * just be zeros.
4943 * the same error again when the RPC is retried.
4945 * RPC to fail later.
4956 * If fnd_init is true, ignore the badslots.
4957 * If fnd_init is false, return NFSERR_SEQMISORDERED if all slots are bad.
4968 /* Find an unused slot. */
4974 /* Just return the bad session. */
4997 * If a forced dismount is in progress, just return.
4999 * newnfs_request().
5005 /* Wake up once/sec, to check for a forced dismount. */
5012 * If all slots are bad, just return slot 0 and NFSERR_SEQMISORDERED.
5014 * will get a NFSERR_BADSESSION reply from the server.
5019 /* Now, find the highest slot in use. (nfsc_slots is 64bits) */
5037 * Free a session slot.
5058 * Search for a matching pnfsd DS, based on the nmp arg.
5059 * Return one if found, NULL otherwise.
5068 * Search the DS server list for a match with nmp.
5082 * Fill in the fields of "struct nfsrv_descript".
5125 * Grow a ext_pgs mbuf list. Either allocate another page or add
5126 * an mbuf to the list.
5151 * Do the NFSv4.1 Destroy Session.