nfs_commonport.c (224079) | nfs_commonport.c (224086) |
---|---|
1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 18 unchanged lines hidden (view full) --- 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 */ 33 34#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 18 unchanged lines hidden (view full) --- 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/fs/nfs/nfs_commonport.c 224079 2011-07-16 08:05:21Z zack $"); | 35__FBSDID("$FreeBSD: head/sys/fs/nfs/nfs_commonport.c 224086 2011-07-16 08:51:09Z zack $"); |
36 37/* 38 * Functions that need to be different for different versions of BSD 39 * kernel should be kept here, along with any global storage specific 40 * to this BSD variant. 41 */ 42#include <fs/nfs/nfsport.h> 43#include <sys/sysctl.h> --- 280 unchanged lines hidden (view full) --- 324 * Only happens if a _PC_xxx is added to the server, 325 * but this isn't updated. 326 */ 327 *retf = 0; 328 printf("nfsrvd pathconf flag=%d not supp\n", flag); 329 }; 330 error = 0; 331 } | 36 37/* 38 * Functions that need to be different for different versions of BSD 39 * kernel should be kept here, along with any global storage specific 40 * to this BSD variant. 41 */ 42#include <fs/nfs/nfsport.h> 43#include <sys/sysctl.h> --- 280 unchanged lines hidden (view full) --- 324 * Only happens if a _PC_xxx is added to the server, 325 * but this isn't updated. 326 */ 327 *retf = 0; 328 printf("nfsrvd pathconf flag=%d not supp\n", flag); 329 }; 330 error = 0; 331 } |
332 NFSEXITCODE(error); |
|
332 return (error); 333} 334 335/* Fake nfsrv_atroot. Just return 0 */ 336int 337nfsrv_atroot(struct vnode *vp, long *retp) 338{ 339 --- 82 unchanged lines hidden (view full) --- 422} 423 424static int 425nfssvc_nfscommon(struct thread *td, struct nfssvc_args *uap) 426{ 427 int error; 428 429 error = nfssvc_call(td, uap, td->td_ucred); | 333 return (error); 334} 335 336/* Fake nfsrv_atroot. Just return 0 */ 337int 338nfsrv_atroot(struct vnode *vp, long *retp) 339{ 340 --- 82 unchanged lines hidden (view full) --- 423} 424 425static int 426nfssvc_nfscommon(struct thread *td, struct nfssvc_args *uap) 427{ 428 int error; 429 430 error = nfssvc_call(td, uap, td->td_ucred); |
431 NFSEXITCODE(error); |
|
430 return (error); 431} 432 433static int 434nfssvc_call(struct thread *p, struct nfssvc_args *uap, struct ucred *cred) 435{ 436 int error = EINVAL; 437 struct nfsd_idargs nid; 438 439 if (uap->flag & NFSSVC_IDNAME) { 440 error = copyin(uap->argp, (caddr_t)&nid, sizeof (nid)); 441 if (error) | 432 return (error); 433} 434 435static int 436nfssvc_call(struct thread *p, struct nfssvc_args *uap, struct ucred *cred) 437{ 438 int error = EINVAL; 439 struct nfsd_idargs nid; 440 441 if (uap->flag & NFSSVC_IDNAME) { 442 error = copyin(uap->argp, (caddr_t)&nid, sizeof (nid)); 443 if (error) |
442 return (error); | 444 goto out; |
443 error = nfssvc_idname(&nid); | 445 error = nfssvc_idname(&nid); |
444 return (error); | 446 goto out; |
445 } else if (uap->flag & NFSSVC_GETSTATS) { 446 error = copyout(&newnfsstats, 447 CAST_USER_ADDR_T(uap->argp), sizeof (newnfsstats)); 448 if (error == 0) { 449 if ((uap->flag & NFSSVC_ZEROCLTSTATS) != 0) { 450 newnfsstats.attrcache_hits = 0; 451 newnfsstats.attrcache_misses = 0; 452 newnfsstats.lookupcache_hits = 0; --- 45 unchanged lines hidden (view full) --- 498 newnfsstats.cllocallockowners = 0; 499 newnfsstats.cllocallocks = 0; 500 bzero(newnfsstats.srvrpccnt, 501 sizeof(newnfsstats.srvrpccnt)); 502 bzero(newnfsstats.cbrpccnt, 503 sizeof(newnfsstats.cbrpccnt)); 504 } 505 } | 447 } else if (uap->flag & NFSSVC_GETSTATS) { 448 error = copyout(&newnfsstats, 449 CAST_USER_ADDR_T(uap->argp), sizeof (newnfsstats)); 450 if (error == 0) { 451 if ((uap->flag & NFSSVC_ZEROCLTSTATS) != 0) { 452 newnfsstats.attrcache_hits = 0; 453 newnfsstats.attrcache_misses = 0; 454 newnfsstats.lookupcache_hits = 0; --- 45 unchanged lines hidden (view full) --- 500 newnfsstats.cllocallockowners = 0; 501 newnfsstats.cllocallocks = 0; 502 bzero(newnfsstats.srvrpccnt, 503 sizeof(newnfsstats.srvrpccnt)); 504 bzero(newnfsstats.cbrpccnt, 505 sizeof(newnfsstats.cbrpccnt)); 506 } 507 } |
506 return (error); | 508 goto out; |
507 } else if (uap->flag & NFSSVC_NFSUSERDPORT) { 508 u_short sockport; 509 510 error = copyin(uap->argp, (caddr_t)&sockport, 511 sizeof (u_short)); 512 if (!error) 513 error = nfsrv_nfsuserdport(sockport, p); 514 } else if (uap->flag & NFSSVC_NFSUSERDDELPORT) { 515 nfsrv_nfsuserddelport(); 516 error = 0; 517 } | 509 } else if (uap->flag & NFSSVC_NFSUSERDPORT) { 510 u_short sockport; 511 512 error = copyin(uap->argp, (caddr_t)&sockport, 513 sizeof (u_short)); 514 if (!error) 515 error = nfsrv_nfsuserdport(sockport, p); 516 } else if (uap->flag & NFSSVC_NFSUSERDDELPORT) { 517 nfsrv_nfsuserddelport(); 518 error = 0; 519 } |
520 521out: 522 NFSEXITCODE(error); |
|
518 return (error); 519} 520 521/* 522 * called by all three modevent routines, so that it gets things 523 * initialized soon enough. 524 */ 525void --- 38 unchanged lines hidden (view full) --- 564nfscommon_modevent(module_t mod, int type, void *data) 565{ 566 int error = 0; 567 static int loaded = 0; 568 569 switch (type) { 570 case MOD_LOAD: 571 if (loaded) | 523 return (error); 524} 525 526/* 527 * called by all three modevent routines, so that it gets things 528 * initialized soon enough. 529 */ 530void --- 38 unchanged lines hidden (view full) --- 569nfscommon_modevent(module_t mod, int type, void *data) 570{ 571 int error = 0; 572 static int loaded = 0; 573 574 switch (type) { 575 case MOD_LOAD: 576 if (loaded) |
572 return (0); | 577 goto out; |
573 newnfs_portinit(); 574 mtx_init(&nfs_nameid_mutex, "nfs_nameid_mutex", NULL, MTX_DEF); 575 mtx_init(&nfs_sockl_mutex, "nfs_sockl_mutex", NULL, MTX_DEF); 576 mtx_init(&nfs_slock_mutex, "nfs_slock_mutex", NULL, MTX_DEF); 577 mtx_init(&nfs_req_mutex, "nfs_req_mutex", NULL, MTX_DEF); 578 mtx_init(&nfsrv_nfsuserdsock.nr_mtx, "nfsuserd", NULL, 579 MTX_DEF); 580 callout_init(&newnfsd_callout, CALLOUT_MPSAFE); --- 20 unchanged lines hidden (view full) --- 601 mtx_destroy(&nfs_req_mutex); 602 mtx_destroy(&nfsrv_nfsuserdsock.nr_mtx); 603 loaded = 0; 604 break; 605 default: 606 error = EOPNOTSUPP; 607 break; 608 } | 578 newnfs_portinit(); 579 mtx_init(&nfs_nameid_mutex, "nfs_nameid_mutex", NULL, MTX_DEF); 580 mtx_init(&nfs_sockl_mutex, "nfs_sockl_mutex", NULL, MTX_DEF); 581 mtx_init(&nfs_slock_mutex, "nfs_slock_mutex", NULL, MTX_DEF); 582 mtx_init(&nfs_req_mutex, "nfs_req_mutex", NULL, MTX_DEF); 583 mtx_init(&nfsrv_nfsuserdsock.nr_mtx, "nfsuserd", NULL, 584 MTX_DEF); 585 callout_init(&newnfsd_callout, CALLOUT_MPSAFE); --- 20 unchanged lines hidden (view full) --- 606 mtx_destroy(&nfs_req_mutex); 607 mtx_destroy(&nfsrv_nfsuserdsock.nr_mtx); 608 loaded = 0; 609 break; 610 default: 611 error = EOPNOTSUPP; 612 break; 613 } |
614 615out: 616 NFSEXITCODE(error); |
|
609 return error; 610} 611static moduledata_t nfscommon_mod = { 612 "nfscommon", 613 nfscommon_modevent, 614 NULL, 615}; 616DECLARE_MODULE(nfscommon, nfscommon_mod, SI_SUB_VFS, SI_ORDER_ANY); 617 618/* So that loader and kldload(2) can find us, wherever we are.. */ 619MODULE_VERSION(nfscommon, 1); 620MODULE_DEPEND(nfscommon, nfssvc, 1, 1, 1); 621MODULE_DEPEND(nfscommon, krpc, 1, 1, 1); 622 | 617 return error; 618} 619static moduledata_t nfscommon_mod = { 620 "nfscommon", 621 nfscommon_modevent, 622 NULL, 623}; 624DECLARE_MODULE(nfscommon, nfscommon_mod, SI_SUB_VFS, SI_ORDER_ANY); 625 626/* So that loader and kldload(2) can find us, wherever we are.. */ 627MODULE_VERSION(nfscommon, 1); 628MODULE_DEPEND(nfscommon, nfssvc, 1, 1, 1); 629MODULE_DEPEND(nfscommon, krpc, 1, 1, 1); 630 |