server: Let the directory code handle device names.

This commit is contained in:
Alexandre Julliard 2005-12-05 14:52:02 +01:00
parent cf21d4d7ca
commit d13095bc84
4 changed files with 20 additions and 17 deletions

View File

@ -283,7 +283,7 @@ void *open_object_dir( struct directory *root, const struct unicode_str *name,
/* Global initialization */ /* Global initialization */
static struct directory *dir_driver; static struct directory *dir_driver, *dir_device;
static struct symlink *link_dosdev, *link_global1, *link_global2, *link_local; static struct symlink *link_dosdev, *link_global1, *link_global2, *link_local;
static struct named_pipe_device *dev_named_pipe; static struct named_pipe_device *dev_named_pipe;
static struct mailslot_device *dev_mailslot; static struct mailslot_device *dev_mailslot;
@ -308,7 +308,13 @@ void init_directories(void)
static const struct unicode_str link_global_str = {link_globalW, sizeof(link_globalW)}; static const struct unicode_str link_global_str = {link_globalW, sizeof(link_globalW)};
static const struct unicode_str link_local_str = {link_localW, sizeof(link_localW)}; static const struct unicode_str link_local_str = {link_localW, sizeof(link_localW)};
struct directory *dir_global, *dir_basenamed, *dir_device; /* devices */
static const WCHAR pipeW[] = {'P','I','P','E'};
static const WCHAR mailslotW[] = {'M','A','I','L','S','L','O','T'};
static const struct unicode_str pipe_str = {pipeW, sizeof(pipeW)};
static const struct unicode_str mailslot_str = {mailslotW, sizeof(mailslotW)};
struct directory *dir_global, *dir_basenamed;
root_directory = create_directory( NULL, NULL, 0, HASH_SIZE ); root_directory = create_directory( NULL, NULL, 0, HASH_SIZE );
dir_driver = create_directory( root_directory, &dir_driver_str, 0, HASH_SIZE ); dir_driver = create_directory( root_directory, &dir_driver_str, 0, HASH_SIZE );
@ -325,11 +331,10 @@ void init_directories(void)
link_local = create_symlink( dir_basenamed, &link_local_str, 0, &dir_basenamed_str ); link_local = create_symlink( dir_basenamed, &link_local_str, 0, &dir_basenamed_str );
/* devices */ /* devices */
dev_named_pipe = create_named_pipe_device(); dev_named_pipe = create_named_pipe_device( dir_global, &pipe_str );
dev_mailslot = create_mailslot_device(); dev_mailslot = create_mailslot_device( dir_global, &mailslot_str );
/* the symlinks or devices hold references so we can release these */ /* the symlinks or devices hold references so we can release these */
release_object( dir_device );
release_object( dir_global ); release_object( dir_global );
release_object( dir_basenamed ); release_object( dir_basenamed );
} }
@ -344,6 +349,7 @@ void close_directories(void)
release_object( link_global2 ); release_object( link_global2 );
release_object( link_local ); release_object( link_local );
release_object( dir_device );
release_object( dir_driver ); release_object( dir_driver );
release_object( root_directory ); release_object( root_directory );
} }

View File

@ -269,13 +269,11 @@ static void mailslot_device_destroy( struct object *obj )
free( device->mailslots ); free( device->mailslots );
} }
struct mailslot_device *create_mailslot_device( void ) struct mailslot_device *create_mailslot_device( struct directory *root, const struct unicode_str *name )
{ {
static const WCHAR mailslotW[] = {'\\','?','?','\\','M','A','I','L','S','L','O','T'};
static struct unicode_str mailslot = {mailslotW, sizeof(mailslotW)};
struct mailslot_device *dev; struct mailslot_device *dev;
if ((dev = create_named_object_dir( NULL, &mailslot, 0, &mailslot_device_ops )) && if ((dev = create_named_object_dir( root, name, 0, &mailslot_device_ops )) &&
get_error() != STATUS_OBJECT_NAME_EXISTS) get_error() != STATUS_OBJECT_NAME_EXISTS)
{ {
if (!(dev->mailslots = create_namespace( 7 ))) if (!(dev->mailslots = create_namespace( 7 )))

View File

@ -379,8 +379,6 @@ static struct object *named_pipe_device_lookup_name( struct object *obj, struct
assert( obj->ops == &named_pipe_device_ops ); assert( obj->ops == &named_pipe_device_ops );
assert( device->pipes ); assert( device->pipes );
if (!name->len) return NULL;
if ((found = find_object( device->pipes, name, attr | OBJ_CASE_INSENSITIVE ))) if ((found = find_object( device->pipes, name, attr | OBJ_CASE_INSENSITIVE )))
name->len = 0; name->len = 0;
@ -397,13 +395,12 @@ static void named_pipe_device_destroy( struct object *obj )
/* this will be deleted as soon an we fix wait_named_pipe */ /* this will be deleted as soon an we fix wait_named_pipe */
static struct named_pipe_device *named_pipe_device; static struct named_pipe_device *named_pipe_device;
struct named_pipe_device *create_named_pipe_device( void ) struct named_pipe_device *create_named_pipe_device( struct directory *root,
const struct unicode_str *name )
{ {
static const WCHAR pipeW[] = {'\\','?','?','\\','P','I','P','E'};
static struct unicode_str pipe = {pipeW, sizeof(pipeW)};
struct named_pipe_device *dev; struct named_pipe_device *dev;
if ((dev = create_named_object_dir( NULL, &pipe, 0, &named_pipe_device_ops )) && if ((dev = create_named_object_dir( root, name, 0, &named_pipe_device_ops )) &&
get_error() != STATUS_OBJECT_NAME_EXISTS) get_error() != STATUS_OBJECT_NAME_EXISTS)
{ {
if (!(dev->pipes = create_namespace( 7 ))) if (!(dev->pipes = create_namespace( 7 )))

View File

@ -198,8 +198,10 @@ extern struct symlink *create_symlink( struct directory *root, const struct unic
unsigned int attr, const struct unicode_str *target ); unsigned int attr, const struct unicode_str *target );
/* devices */ /* devices */
extern struct named_pipe_device *create_named_pipe_device( void ); extern struct named_pipe_device *create_named_pipe_device( struct directory *root,
extern struct mailslot_device *create_mailslot_device( void ); const struct unicode_str *name );
extern struct mailslot_device *create_mailslot_device( struct directory *root,
const struct unicode_str *name );
/* global variables */ /* global variables */