1 |
/* Hierarchial filesystem support |
/* Hierarchial filesystem support |
2 |
|
|
3 |
Copyright (C) 1995 Free Software Foundation, Inc. |
Copyright (C) 1995, 2002 Free Software Foundation, Inc. |
4 |
|
|
5 |
Written by Miles Bader <miles@gnu.ai.mit.edu> |
Written by Miles Bader <miles@gnu.org> |
6 |
|
|
7 |
This file is part of the GNU Hurd. |
This file is part of the GNU Hurd. |
8 |
|
|
84 |
}; |
}; |
85 |
|
|
86 |
/* A filesystem node in the tree. */ |
/* A filesystem node in the tree. */ |
87 |
struct treefs_node |
struct treefs_node |
88 |
{ |
{ |
89 |
struct stat stat; |
io_statbuf_t stat; |
90 |
struct treefs_fsys *fsys; |
struct treefs_fsys *fsys; |
91 |
|
|
92 |
struct trans_link active_trans; |
struct trans_link active_trans; |
124 |
/* The port for the node which this filesystem is translating. */ |
/* The port for the node which this filesystem is translating. */ |
125 |
mach_port_t underlying_port; |
mach_port_t underlying_port; |
126 |
/* And stat info for it. */ |
/* And stat info for it. */ |
127 |
struct stat underlying_stat; |
io_statbuf_t underlying_stat; |
128 |
|
|
129 |
/* Flags from the TREEFS_FSYS_ set. */ |
/* Flags from the TREEFS_FSYS_ set. */ |
130 |
int flags; |
int flags; |
237 |
|
|
238 |
extern spin_lock_t treefs_node_refcnt_lock; |
extern spin_lock_t treefs_node_refcnt_lock; |
239 |
|
|
240 |
/* Add a hard reference to a node. If there were no hard |
/* Add a hard reference to a node. If there were no hard |
241 |
references previously, then the node cannot be locked |
references previously, then the node cannot be locked |
242 |
(because you must hold a hard reference to hold the lock). */ |
(because you must hold a hard reference to hold the lock). */ |
243 |
extern inline void |
extern inline void |
244 |
treefs_node_ref (struct treefs_node *node) |
treefs_node_ref (struct treefs_node *node) |
263 |
treefs_node_release (struct treefs_node *node) |
treefs_node_release (struct treefs_node *node) |
264 |
{ |
{ |
265 |
int tried_drop_weak_refs = 0; |
int tried_drop_weak_refs = 0; |
266 |
|
|
267 |
loop: |
loop: |
268 |
spin_lock (&treefs_node_refcnt_lock); |
spin_lock (&treefs_node_refcnt_lock); |
269 |
assert (node->refs); |
assert (node->refs); |
310 |
treefs_node_unref (struct treefs_node *node) |
treefs_node_unref (struct treefs_node *node) |
311 |
{ |
{ |
312 |
int tried_drop_weak_refs = 0; |
int tried_drop_weak_refs = 0; |
313 |
|
|
314 |
loop: |
loop: |
315 |
spin_lock (&treefs_node_refcnt_lock); |
spin_lock (&treefs_node_refcnt_lock); |
316 |
assert (node->refs); |
assert (node->refs); |
331 |
spin_unlock (&treefs_node_refcnt_lock); |
spin_unlock (&treefs_node_refcnt_lock); |
332 |
node->refs++; |
node->refs++; |
333 |
spin_unlock (&treefs_node_refcnt_lock); |
spin_unlock (&treefs_node_refcnt_lock); |
334 |
|
|
335 |
treefs_node_try_dropping_weak_refs (node); |
treefs_node_try_dropping_weak_refs (node); |
336 |
tried_drop_weak_refs = 1; |
tried_drop_weak_refs = 1; |
337 |
|
|
372 |
|
|
373 |
/* Release a weak reference on NODE. If NODE is locked by anyone, then |
/* Release a weak reference on NODE. If NODE is locked by anyone, then |
374 |
this cannot be the last reference (because you must hold a |
this cannot be the last reference (because you must hold a |
375 |
hard reference in order to hold the lock). */ |
hard reference in order to hold the lock). */ |
376 |
extern inline void |
extern inline void |
377 |
treefs_node_unref_weak (struct treefs_node *node) |
treefs_node_unref_weak (struct treefs_node *node) |
378 |
{ |
{ |