vfs_subr.c (8947be9ba004add6deae3c56398bed461c4995f1) | vfs_subr.c (5965373e69ca208cedd8ede9716ef0d58e6c3434) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 2616 unchanged lines hidden (view full) --- 2625 nmp = TAILQ_NEXT(mp, mnt_list); 2626 vfs_unbusy(mp, td); 2627 } 2628 mtx_unlock(&mountlist_mtx); 2629} 2630#endif 2631 2632/* | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 2616 unchanged lines hidden (view full) --- 2625 nmp = TAILQ_NEXT(mp, mnt_list); 2626 vfs_unbusy(mp, td); 2627 } 2628 mtx_unlock(&mountlist_mtx); 2629} 2630#endif 2631 2632/* |
2633 * Fill in a struct xvfsconf based on a struct vfsconf. 2634 */ 2635static void 2636vfsconf2x(struct vfsconf *vfsp, struct xvfsconf *xvfsp) 2637{ 2638 2639 strcpy(xvfsp->vfc_name, vfsp->vfc_name); 2640 xvfsp->vfc_typenum = vfsp->vfc_typenum; 2641 xvfsp->vfc_refcount = vfsp->vfc_refcount; 2642 xvfsp->vfc_flags = vfsp->vfc_flags; 2643 /* 2644 * These are unused in userland, we keep them 2645 * to not break binary compatibility. 2646 */ 2647 xvfsp->vfc_vfsops = NULL; 2648 xvfsp->vfc_next = NULL; 2649} 2650 2651static int 2652sysctl_vfs_conflist(SYSCTL_HANDLER_ARGS) 2653{ 2654 struct vfsconf *vfsp; 2655 struct xvfsconf *xvfsp; 2656 int cnt, error, i; 2657 2658 cnt = 0; 2659 for (vfsp = vfsconf; vfsp != NULL; vfsp = vfsp->vfc_next) 2660 cnt++; 2661 xvfsp = malloc(sizeof(struct xvfsconf) * cnt, M_TEMP, M_WAITOK); 2662 /* 2663 * Handle the race that we will have here when struct vfsconf 2664 * will be locked down by using both cnt and checking vfc_next 2665 * against NULL to determine the end of the loop. The race will 2666 * happen because we will have to unlock before calling malloc(). 2667 * We are protected by Giant for now. 2668 */ 2669 i = 0; 2670 for (vfsp = vfsconf; vfsp != NULL && i < cnt; vfsp = vfsp->vfc_next) { 2671 vfsconf2x(vfsp, xvfsp + i); 2672 i++; 2673 } 2674 error = SYSCTL_OUT(req, xvfsp, sizeof(struct xvfsconf) * i); 2675 free(xvfsp, M_TEMP); 2676 return (error); 2677} 2678 2679SYSCTL_PROC(_vfs, OID_AUTO, conflist, CTLFLAG_RD, NULL, 0, sysctl_vfs_conflist, 2680 "S,xvfsconf", "List of all configured filesystems"); 2681 2682/* |
|
2633 * Top level filesystem related information gathering. 2634 */ 2635static int sysctl_ovfs_conf(SYSCTL_HANDLER_ARGS); 2636 2637static int 2638vfs_sysctl(SYSCTL_HANDLER_ARGS) 2639{ 2640 int *name = (int *)arg1 - 1; /* XXX */ 2641 u_int namelen = arg2 + 1; /* XXX */ 2642 struct vfsconf *vfsp; | 2683 * Top level filesystem related information gathering. 2684 */ 2685static int sysctl_ovfs_conf(SYSCTL_HANDLER_ARGS); 2686 2687static int 2688vfs_sysctl(SYSCTL_HANDLER_ARGS) 2689{ 2690 int *name = (int *)arg1 - 1; /* XXX */ 2691 u_int namelen = arg2 + 1; /* XXX */ 2692 struct vfsconf *vfsp; |
2693 struct xvfsconf xvfsp; |
|
2643 | 2694 |
2695 printf("WARNING: userland calling deprecated sysctl, " 2696 "please rebuild world\n"); 2697 |
|
2644#if 1 || defined(COMPAT_PRELITE2) 2645 /* Resolve ambiguity between VFS_VFSCONF and VFS_GENERIC. */ 2646 if (namelen == 1) 2647 return (sysctl_ovfs_conf(oidp, arg1, arg2, req)); 2648#endif 2649 | 2698#if 1 || defined(COMPAT_PRELITE2) 2699 /* Resolve ambiguity between VFS_VFSCONF and VFS_GENERIC. */ 2700 if (namelen == 1) 2701 return (sysctl_ovfs_conf(oidp, arg1, arg2, req)); 2702#endif 2703 |
2650 /* XXX the below code does not compile; vfs_sysctl does not exist. */ 2651#ifdef notyet 2652 /* all sysctl names at this level are at least name and field */ 2653 if (namelen < 2) 2654 return (ENOTDIR); /* overloaded */ 2655 if (name[0] != VFS_GENERIC) { 2656 for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) 2657 if (vfsp->vfc_typenum == name[0]) 2658 break; 2659 if (vfsp == NULL) 2660 return (EOPNOTSUPP); 2661 return ((*vfsp->vfc_vfsops->vfs_sysctl)(&name[1], namelen - 1, 2662 oldp, oldlenp, newp, newlen, td)); 2663 } 2664#endif | |
2665 switch (name[1]) { 2666 case VFS_MAXTYPENUM: 2667 if (namelen != 2) 2668 return (ENOTDIR); 2669 return (SYSCTL_OUT(req, &maxvfsconf, sizeof(int))); 2670 case VFS_CONF: 2671 if (namelen != 3) 2672 return (ENOTDIR); /* overloaded */ 2673 for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) 2674 if (vfsp->vfc_typenum == name[2]) 2675 break; 2676 if (vfsp == NULL) 2677 return (EOPNOTSUPP); | 2704 switch (name[1]) { 2705 case VFS_MAXTYPENUM: 2706 if (namelen != 2) 2707 return (ENOTDIR); 2708 return (SYSCTL_OUT(req, &maxvfsconf, sizeof(int))); 2709 case VFS_CONF: 2710 if (namelen != 3) 2711 return (ENOTDIR); /* overloaded */ 2712 for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) 2713 if (vfsp->vfc_typenum == name[2]) 2714 break; 2715 if (vfsp == NULL) 2716 return (EOPNOTSUPP); |
2678 return (SYSCTL_OUT(req, vfsp, sizeof *vfsp)); | 2717 vfsconf2x(vfsp, &xvfsp); 2718 return (SYSCTL_OUT(req, &xvfsp, sizeof(xvfsp))); |
2679 } 2680 return (EOPNOTSUPP); 2681} 2682 | 2719 } 2720 return (EOPNOTSUPP); 2721} 2722 |
2683SYSCTL_NODE(_vfs, VFS_GENERIC, generic, CTLFLAG_RD, vfs_sysctl, | 2723SYSCTL_NODE(_vfs, VFS_GENERIC, generic, CTLFLAG_RD | CTLFLAG_SKIP, vfs_sysctl, |
2684 "Generic filesystem"); 2685 2686#if 1 || defined(COMPAT_PRELITE2) 2687 2688static int 2689sysctl_ovfs_conf(SYSCTL_HANDLER_ARGS) 2690{ 2691 int error; --- 762 unchanged lines hidden --- | 2724 "Generic filesystem"); 2725 2726#if 1 || defined(COMPAT_PRELITE2) 2727 2728static int 2729sysctl_ovfs_conf(SYSCTL_HANDLER_ARGS) 2730{ 2731 int error; --- 762 unchanged lines hidden --- |