diff options
Diffstat (limited to 'libdiskfs/peropen-make.c')
-rw-r--r-- | libdiskfs/peropen-make.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/libdiskfs/peropen-make.c b/libdiskfs/peropen-make.c index de483f26..d37516c1 100644 --- a/libdiskfs/peropen-make.c +++ b/libdiskfs/peropen-make.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994 Free Software Foundation + Copyright (C) 1994,97,99,2001,02 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -20,19 +20,45 @@ /* Create and return a new peropen structure on node NP with open flags FLAGS. */ -struct peropen * -diskfs_make_peropen (struct node *np, int flags, mach_port_t dotdotport) +error_t +diskfs_make_peropen (struct node *np, int flags, struct peropen *context, + struct peropen **ppo) { - struct peropen *po = malloc (sizeof (struct peropen)); + struct peropen *po = *ppo = malloc (sizeof (struct peropen)); + + if (! po) + return ENOMEM; + po->filepointer = 0; po->lock_status = LOCK_UN; po->refcnt = 0; po->openstat = flags; po->np = np; - po->dotdotport = dotdotport; - if (dotdotport != MACH_PORT_NULL) - mach_port_mod_refs (mach_task_self (), dotdotport, - MACH_PORT_RIGHT_SEND, 1); + + if (context) + { + po->root_parent = context->root_parent; + if (po->root_parent != MACH_PORT_NULL) + mach_port_mod_refs (mach_task_self (), po->root_parent, + MACH_PORT_RIGHT_SEND, 1); + + po->shadow_root = context->shadow_root; + if (po->shadow_root) + diskfs_nref (po->shadow_root); + + po->shadow_root_parent = context->shadow_root_parent; + if (po->shadow_root_parent != MACH_PORT_NULL) + mach_port_mod_refs (mach_task_self (), po->shadow_root_parent, + MACH_PORT_RIGHT_SEND, 1); + } + else + { + po->root_parent = MACH_PORT_NULL; + po->shadow_root_parent = MACH_PORT_NULL; + po->shadow_root = _diskfs_chroot_directory ? diskfs_root_node : 0; + } + diskfs_nref (np); - return po; + + return 0; } |