Deleted Added
full compact
pseudofs_fileno.c (143841) pseudofs_fileno.c (168637)
1/*-
2 * Copyright (c) 2001 Dag-Erling Co�dan Sm�rgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Dag-Erling Co�dan Sm�rgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/fs/pseudofs/pseudofs_fileno.c 143841 2005-03-19 08:22:36Z phk $");
30__FBSDID("$FreeBSD: head/sys/fs/pseudofs/pseudofs_fileno.c 168637 2007-04-11 22:40:57Z des $");
31
32#include "opt_pseudofs.h"
33
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/systm.h>
37#include <sys/limits.h>
38#include <sys/lock.h>
39#include <sys/malloc.h>
40#include <sys/mutex.h>
41#include <sys/sysctl.h>
31
32#include "opt_pseudofs.h"
33
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/systm.h>
37#include <sys/limits.h>
38#include <sys/lock.h>
39#include <sys/malloc.h>
40#include <sys/mutex.h>
41#include <sys/sysctl.h>
42#include <sys/systm.h>
42
43#include <fs/pseudofs/pseudofs.h>
44#include <fs/pseudofs/pseudofs_internal.h>
45
46/*
47 * Initialize fileno bitmap
48 */
49void
50pfs_fileno_init(struct pfs_info *pi)
51{
52 struct unrhdr *up;
53
54 up = new_unrhdr(3, INT_MAX, &pi->pi_mutex);
55 mtx_lock(&pi->pi_mutex);
56 pi->pi_unrhdr = up;
43
44#include <fs/pseudofs/pseudofs.h>
45#include <fs/pseudofs/pseudofs_internal.h>
46
47/*
48 * Initialize fileno bitmap
49 */
50void
51pfs_fileno_init(struct pfs_info *pi)
52{
53 struct unrhdr *up;
54
55 up = new_unrhdr(3, INT_MAX, &pi->pi_mutex);
56 mtx_lock(&pi->pi_mutex);
57 pi->pi_unrhdr = up;
57 pi->pi_root->pn_fileno = 2;
58 mtx_unlock(&pi->pi_mutex);
59}
60
61/*
62 * Tear down fileno bitmap
63 */
64void
65pfs_fileno_uninit(struct pfs_info *pi)

--- 11 unchanged lines hidden (view full) ---

77}
78
79/*
80 * Allocate a file number
81 */
82void
83pfs_fileno_alloc(struct pfs_info *pi, struct pfs_node *pn)
84{
58 mtx_unlock(&pi->pi_mutex);
59}
60
61/*
62 * Tear down fileno bitmap
63 */
64void
65pfs_fileno_uninit(struct pfs_info *pi)

--- 11 unchanged lines hidden (view full) ---

77}
78
79/*
80 * Allocate a file number
81 */
82void
83pfs_fileno_alloc(struct pfs_info *pi, struct pfs_node *pn)
84{
85 /* pi is not really necessary as it can be derived */
86 KASSERT(pi == pn->pn_info, ("pn / pi mismatch"));
87
85 /* make sure our parent has a file number */
86 if (pn->pn_parent && !pn->pn_parent->pn_fileno)
87 pfs_fileno_alloc(pi, pn->pn_parent);
88
89 switch (pn->pn_type) {
90 case pfstype_root:
88 /* make sure our parent has a file number */
89 if (pn->pn_parent && !pn->pn_parent->pn_fileno)
90 pfs_fileno_alloc(pi, pn->pn_parent);
91
92 switch (pn->pn_type) {
93 case pfstype_root:
94 /* root must always be 2 */
95 pn->pn_fileno = 2;
96 break;
91 case pfstype_dir:
92 case pfstype_file:
93 case pfstype_symlink:
94 case pfstype_procdir:
95 pn->pn_fileno = alloc_unr(pi->pi_unrhdr);
96 break;
97 case pfstype_this:
98 KASSERT(pn->pn_parent != NULL,

--- 30 unchanged lines hidden (view full) ---

129}
130
131/*
132 * Release a file number
133 */
134void
135pfs_fileno_free(struct pfs_info *pi, struct pfs_node *pn)
136{
97 case pfstype_dir:
98 case pfstype_file:
99 case pfstype_symlink:
100 case pfstype_procdir:
101 pn->pn_fileno = alloc_unr(pi->pi_unrhdr);
102 break;
103 case pfstype_this:
104 KASSERT(pn->pn_parent != NULL,

--- 30 unchanged lines hidden (view full) ---

135}
136
137/*
138 * Release a file number
139 */
140void
141pfs_fileno_free(struct pfs_info *pi, struct pfs_node *pn)
142{
143 /* pi is not really necessary as it can be derived */
144 KASSERT(pi == pn->pn_info, ("pn / pi mismatch"));
145
137 switch (pn->pn_type) {
138 case pfstype_root:
146 switch (pn->pn_type) {
147 case pfstype_root:
148 /* not allocated from unrhdr */
149 return;
139 case pfstype_dir:
140 case pfstype_file:
141 case pfstype_symlink:
142 case pfstype_procdir:
143 free_unr(pi->pi_unrhdr, pn->pn_fileno);
144 break;
145 case pfstype_this:
146 case pfstype_parent:
147 /* ignore these, as they don't "own" their file number */
148 break;
149 case pfstype_none:
150 KASSERT(0,
151 ("pfs_fileno_free() called for pfstype_none node"));
152 break;
153 }
154}
150 case pfstype_dir:
151 case pfstype_file:
152 case pfstype_symlink:
153 case pfstype_procdir:
154 free_unr(pi->pi_unrhdr, pn->pn_fileno);
155 break;
156 case pfstype_this:
157 case pfstype_parent:
158 /* ignore these, as they don't "own" their file number */
159 break;
160 case pfstype_none:
161 KASSERT(0,
162 ("pfs_fileno_free() called for pfstype_none node"));
163 break;
164 }
165}