object.c 19.3 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3 4
/*
 * Server-side objects
 *
 * Copyright (C) 1998 Alexandre Julliard
5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliard's avatar
Alexandre Julliard committed
19 20
 */

21 22
#include "config.h"

Alexandre Julliard's avatar
Alexandre Julliard committed
23
#include <assert.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
24
#include <limits.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
25
#include <stdlib.h>
26
#include <stdio.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
27
#include <string.h>
28
#include <unistd.h>
29
#include <stdarg.h>
30
#include <sys/types.h>
31 32 33
#ifdef HAVE_VALGRIND_MEMCHECK_H
#include <valgrind/memcheck.h>
#endif
Alexandre Julliard's avatar
Alexandre Julliard committed
34

35 36
#include "ntstatus.h"
#define WIN32_NO_STATUS
37 38
#include "winternl.h"

39
#include "file.h"
40
#include "process.h"
41
#include "thread.h"
42
#include "unicode.h"
43
#include "security.h"
Alexandre Julliard's avatar
Alexandre Julliard committed
44

Alexandre Julliard's avatar
Alexandre Julliard committed
45

46 47 48 49 50
struct namespace
{
    unsigned int        hash_size;       /* size of hash table */
    struct list         names[1];        /* array of hash entry lists */
};
Alexandre Julliard's avatar
Alexandre Julliard committed
51 52


53 54 55 56 57 58 59 60 61 62 63
struct type_descr no_type =
{
    { NULL, 0 },                /* name */
    STANDARD_RIGHTS_REQUIRED,   /* valid_access */
    {                           /* mapping */
        STANDARD_RIGHTS_READ,
        STANDARD_RIGHTS_WRITE,
        STANDARD_RIGHTS_EXECUTE,
        STANDARD_RIGHTS_REQUIRED
    },
};
64

65
#ifdef DEBUG_OBJECTS
66
static struct list object_list = LIST_INIT(object_list);
67 68 69

void dump_objects(void)
{
70
    struct object *ptr;
71

72
    LIST_FOR_EACH_ENTRY( ptr, &object_list, struct object, obj_list )
73
    {
74
        fprintf( stderr, "%p:%d: ", ptr, ptr->refcount );
75
        dump_object_name( ptr );
76 77 78
        ptr->ops->dump( ptr, 1 );
    }
}
79 80 81

void close_objects(void)
{
82
    /* release the permanent objects */
83 84 85 86 87 88 89 90 91 92 93 94 95 96
    for (;;)
    {
        struct object *obj;
        int found = 0;

        LIST_FOR_EACH_ENTRY( obj, &object_list, struct object, obj_list )
        {
            if (!(found = obj->is_permanent)) continue;
            obj->is_permanent = 0;
            release_object( obj );
            break;
        }
        if (!found) break;
    }
97 98 99 100 101

    dump_objects();  /* dump any remaining objects */
}

#endif  /* DEBUG_OBJECTS */
102

Alexandre Julliard's avatar
Alexandre Julliard committed
103 104
/*****************************************************************/

105 106 107 108 109 110 111 112 113 114 115
/* mark a block of memory as uninitialized for debugging purposes */
static inline void mark_block_uninitialized( void *ptr, size_t size )
{
    memset( ptr, 0x55, size );
#if defined(VALGRIND_MAKE_MEM_UNDEFINED)
    VALGRIND_DISCARD( VALGRIND_MAKE_MEM_UNDEFINED( ptr, size ));
#elif defined(VALGRIND_MAKE_WRITABLE)
    VALGRIND_DISCARD( VALGRIND_MAKE_WRITABLE( ptr, size ));
#endif
}

116
/* malloc replacement */
Alexandre Julliard's avatar
Alexandre Julliard committed
117 118 119
void *mem_alloc( size_t size )
{
    void *ptr = malloc( size );
120
    if (ptr) mark_block_uninitialized( ptr, size );
121
    else set_error( STATUS_NO_MEMORY );
Alexandre Julliard's avatar
Alexandre Julliard committed
122 123 124
    return ptr;
}

125 126 127
/* duplicate a block of memory */
void *memdup( const void *data, size_t len )
{
Alexandre Julliard's avatar
Alexandre Julliard committed
128
    void *ptr = malloc( len );
129
    if (ptr) memcpy( ptr, data, len );
130
    else set_error( STATUS_NO_MEMORY );
131 132 133 134
    return ptr;
}


Alexandre Julliard's avatar
Alexandre Julliard committed
135 136
/*****************************************************************/

137 138
void namespace_add( struct namespace *namespace, struct object_name *ptr )
{
139
    unsigned int hash = hash_strW( ptr->name, ptr->len, namespace->hash_size );
140 141 142 143

    list_add_head( &namespace->names[hash], &ptr->entry );
}

144
/* allocate a name for an object */
145
static struct object_name *alloc_name( const struct unicode_str *name )
Alexandre Julliard's avatar
Alexandre Julliard committed
146 147 148
{
    struct object_name *ptr;

149
    if ((ptr = mem_alloc( sizeof(*ptr) + name->len - sizeof(ptr->name) )))
150
    {
151
        ptr->len = name->len;
152
        ptr->parent = NULL;
153
        memcpy( ptr->name, name->str, name->len );
154
    }
Alexandre Julliard's avatar
Alexandre Julliard committed
155 156 157
    return ptr;
}

158
/* get the name of an existing object */
159
const WCHAR *get_object_name( struct object *obj, data_size_t *len )
160 161 162 163 164 165 166
{
    struct object_name *ptr = obj->name;
    if (!ptr) return NULL;
    *len = ptr->len;
    return ptr->name;
}

167
/* get the full path name of an existing object */
168
WCHAR *default_get_full_name( struct object *obj, data_size_t *ret_len )
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
{
    static const WCHAR backslash = '\\';
    struct object *ptr = obj;
    data_size_t len = 0;
    char *ret;

    while (ptr && ptr->name)
    {
        struct object_name *name = ptr->name;
        len += name->len + sizeof(WCHAR);
        ptr = name->parent;
    }
    if (!len) return NULL;
    if (!(ret = malloc( len ))) return NULL;

    *ret_len = len;
    while (obj && obj->name)
    {
        struct object_name *name = obj->name;
        memcpy( ret + len - name->len, name->name, name->len );
        len -= name->len + sizeof(WCHAR);
        memcpy( ret + len, &backslash, sizeof(WCHAR) );
        obj = name->parent;
    }
    return (WCHAR *)ret;
}

196
/* allocate and initialize an object */
197
void *alloc_object( const struct object_ops *ops )
198
{
199 200 201
    struct object *obj = mem_alloc( ops->size );
    if (obj)
    {
202 203
        obj->refcount     = 1;
        obj->handle_count = 0;
204
        obj->is_permanent = 0;
205 206 207
        obj->ops          = ops;
        obj->name         = NULL;
        obj->sd           = NULL;
208
        list_init( &obj->wait_queue );
209
#ifdef DEBUG_OBJECTS
210
        list_add_head( &object_list, &obj->obj_list );
211
#endif
212 213
        obj->ops->type->obj_count++;
        obj->ops->type->obj_max = max( obj->ops->type->obj_max, obj->ops->type->obj_count );
214
        return obj;
215
    }
216
    return NULL;
217 218
}

219
/* free an object once it has been destroyed */
220
static void free_object( struct object *obj )
221 222
{
    free( obj->sd );
223
    obj->ops->type->obj_count--;
224 225 226 227 228 229 230
#ifdef DEBUG_OBJECTS
    list_remove( &obj->obj_list );
    memset( obj, 0xaa, obj->ops->size );
#endif
    free( obj );
}

231 232 233 234 235 236
/* find an object by name starting from the specified root */
/* if it doesn't exist, its parent is returned, and name_left contains the remaining name */
struct object *lookup_named_object( struct object *root, const struct unicode_str *name,
                                    unsigned int attr, struct unicode_str *name_left )
{
    struct object *obj, *parent;
237
    struct unicode_str name_tmp = *name, *ptr = &name_tmp;
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258

    if (root)
    {
        /* if root is specified path shouldn't start with backslash */
        if (name_tmp.len && name_tmp.str[0] == '\\')
        {
            set_error( STATUS_OBJECT_PATH_SYNTAX_BAD );
            return NULL;
        }
        parent = grab_object( root );
    }
    else
    {
        if (!name_tmp.len || name_tmp.str[0] != '\\')
        {
            set_error( STATUS_OBJECT_PATH_SYNTAX_BAD );
            return NULL;
        }
        /* skip leading backslash */
        name_tmp.str++;
        name_tmp.len -= sizeof(WCHAR);
259
        parent = root = get_root_directory();
260 261
    }

262
    if (!name_tmp.len) ptr = NULL;  /* special case for empty path */
263

264 265
    clear_error();

266
    while ((obj = parent->ops->lookup_name( parent, ptr, attr, root )))
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
    {
        /* move to the next element */
        release_object ( parent );
        parent = obj;
    }
    if (get_error())
    {
        release_object( parent );
        return NULL;
    }

    if (name_left) *name_left = name_tmp;
    return parent;
}

282 283 284 285 286 287 288 289 290
/* return length of first path element in name */
data_size_t get_path_element( const WCHAR *name, data_size_t len )
{
    data_size_t i;

    for (i = 0; i < len / sizeof(WCHAR); i++) if (name[i] == '\\') break;
    return i * sizeof(WCHAR);
}

291
static struct object *create_object( struct object *parent, const struct object_ops *ops,
292 293
                                     const struct unicode_str *name, unsigned int attributes,
                                     const struct security_descriptor *sd )
294 295 296 297 298
{
    struct object *obj;
    struct object_name *name_ptr;

    if (!(name_ptr = alloc_name( name ))) return NULL;
299 300 301 302 303 304 305 306
    if (!(obj = alloc_object( ops ))) goto failed;
    if (sd && !default_set_sd( obj, sd, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION |
                               DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION ))
        goto failed;
    if (!obj->ops->link_name( obj, name_ptr, parent )) goto failed;

    name_ptr->obj = obj;
    obj->name = name_ptr;
307
    return obj;
308 309 310 311 312

failed:
    if (obj) free_object( obj );
    free( name_ptr );
    return NULL;
313 314
}

315 316
/* create an object as named child under the specified parent */
void *create_named_object( struct object *parent, const struct object_ops *ops,
317 318
                           const struct unicode_str *name, unsigned int attributes,
                           const struct security_descriptor *sd )
Alexandre Julliard's avatar
Alexandre Julliard committed
319
{
320 321
    struct object *obj, *new_obj;
    struct unicode_str new_name;
322

323
    clear_error();
324

325 326 327 328 329 330 331 332 333
    if (!name || !name->len)
    {
        if (!(new_obj = alloc_object( ops ))) return NULL;
        if (sd && !default_set_sd( new_obj, sd, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION |
                                   DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION ))
        {
            free_object( new_obj );
            return NULL;
        }
334
        goto done;
335
    }
336 337 338 339

    if (!(obj = lookup_named_object( parent, name, attributes, &new_name ))) return NULL;

    if (!new_name.len)
Alexandre Julliard's avatar
Alexandre Julliard committed
340
    {
341 342 343
        if (attributes & OBJ_OPENIF && obj->ops == ops)
            set_error( STATUS_OBJECT_NAME_EXISTS );
        else
Alexandre Julliard's avatar
Alexandre Julliard committed
344
        {
345 346
            release_object( obj );
            obj = NULL;
347 348 349 350
            if (attributes & OBJ_OPENIF)
                set_error( STATUS_OBJECT_TYPE_MISMATCH );
            else
                set_error( STATUS_OBJECT_NAME_COLLISION );
Alexandre Julliard's avatar
Alexandre Julliard committed
351
        }
352
        return obj;
Alexandre Julliard's avatar
Alexandre Julliard committed
353
    }
354

355
    new_obj = create_object( obj, ops, &new_name, attributes, sd );
356
    release_object( obj );
357 358 359 360

done:
    if (attributes & OBJ_PERMANENT)
    {
361
        make_object_permanent( new_obj );
362 363
        grab_object( new_obj );
    }
364
    return new_obj;
Alexandre Julliard's avatar
Alexandre Julliard committed
365 366
}

367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
/* open a object by name under the specified parent */
void *open_named_object( struct object *parent, const struct object_ops *ops,
                         const struct unicode_str *name, unsigned int attributes )
{
    struct unicode_str name_left;
    struct object *obj;

    if ((obj = lookup_named_object( parent, name, attributes, &name_left )))
    {
        if (name_left.len) /* not fully parsed */
            set_error( STATUS_OBJECT_NAME_NOT_FOUND );
        else if (ops && obj->ops != ops)
            set_error( STATUS_OBJECT_TYPE_MISMATCH );
        else
            return obj;

        release_object( obj );
    }
    return NULL;
}

388 389 390 391 392 393 394 395
/* recursive helper for dump_object_name */
static void dump_name( struct object *obj )
{
    struct object_name *name = obj->name;

    if (!name) return;
    if (name->parent) dump_name( name->parent );
    fputs( "\\\\", stderr );
396
    dump_strW( name->name, name->len, stderr, "[]" );
397 398
}

399 400
/* dump the name of an object to stderr */
void dump_object_name( struct object *obj )
401
{
402 403 404 405
    if (!obj->name) return;
    fputc( '[', stderr );
    dump_name( obj );
    fputs( "] ", stderr );
406 407
}

408 409 410
/* unlink a named object from its namespace, without freeing the object itself */
void unlink_named_object( struct object *obj )
{
411 412 413
    struct object_name *name_ptr = obj->name;

    if (!name_ptr) return;
414
    obj->name = NULL;
415 416 417
    obj->ops->unlink_name( obj, name_ptr );
    if (name_ptr->parent) release_object( name_ptr->parent );
    free( name_ptr );
418 419
}

Alexandre Julliard's avatar
Alexandre Julliard committed
420 421 422 423 424 425 426 427 428 429
/* grab an object (i.e. increment its refcount) and return the object */
struct object *grab_object( void *ptr )
{
    struct object *obj = (struct object *)ptr;
    assert( obj->refcount < INT_MAX );
    obj->refcount++;
    return obj;
}

/* release an object (i.e. decrement its refcount) */
Alexandre Julliard's avatar
Alexandre Julliard committed
430 431 432 433 434 435
void release_object( void *ptr )
{
    struct object *obj = (struct object *)ptr;
    assert( obj->refcount );
    if (!--obj->refcount)
    {
436
        assert( !obj->handle_count );
Alexandre Julliard's avatar
Alexandre Julliard committed
437
        /* if the refcount is 0, nobody can be in the wait queue */
438
        assert( list_empty( &obj->wait_queue ));
439
        free_kernel_objects( obj );
440
        unlink_named_object( obj );
441
        obj->ops->destroy( obj );
442
        free_object( obj );
Alexandre Julliard's avatar
Alexandre Julliard committed
443 444 445 446
    }
}

/* find an object by its name; the refcount is incremented */
447
struct object *find_object( const struct namespace *namespace, const struct unicode_str *name,
448
                            unsigned int attributes )
Alexandre Julliard's avatar
Alexandre Julliard committed
449
{
450 451
    const struct list *list;
    struct list *p;
452

453
    if (!name || !name->len) return NULL;
454

455
    list = &namespace->names[ hash_strW( name->str, name->len, namespace->hash_size ) ];
456
    LIST_FOR_EACH( p, list )
457
    {
458
        const struct object_name *ptr = LIST_ENTRY( p, struct object_name, entry );
459
        if (ptr->len != name->len) continue;
460
        if (attributes & OBJ_CASE_INSENSITIVE)
461
        {
462
            if (!memicmp_strW( ptr->name, name->str, name->len ))
463
                return grab_object( ptr->obj );
464
        }
465
        else
466
        {
467 468
            if (!memcmp( ptr->name, name->str, name->len ))
                return grab_object( ptr->obj );
469
        }
470 471
    }
    return NULL;
Alexandre Julliard's avatar
Alexandre Julliard committed
472
}
473

474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
/* find an object by its index; the refcount is incremented */
struct object *find_object_index( const struct namespace *namespace, unsigned int index )
{
    unsigned int i;

    /* FIXME: not efficient at all */
    for (i = 0; i < namespace->hash_size; i++)
    {
        const struct object_name *ptr;
        LIST_FOR_EACH_ENTRY( ptr, &namespace->names[i], const struct object_name, entry )
        {
            if (!index--) return grab_object( ptr->obj );
        }
    }
    set_error( STATUS_NO_MORE_ENTRIES );
    return NULL;
}

492
/* allocate a namespace */
493
struct namespace *create_namespace( unsigned int hash_size )
494 495 496 497 498 499 500 501 502 503 504 505 506
{
    struct namespace *namespace;
    unsigned int i;

    namespace = mem_alloc( sizeof(*namespace) + (hash_size - 1) * sizeof(namespace->names[0]) );
    if (namespace)
    {
        namespace->hash_size      = hash_size;
        for (i = 0; i < hash_size; i++) list_init( &namespace->names[i] );
    }
    return namespace;
}

507
/* functions for unimplemented/default object operations */
508

509 510
int no_add_queue( struct object *obj, struct wait_queue_entry *entry )
{
511
    set_error( STATUS_OBJECT_TYPE_MISMATCH );
512 513 514
    return 0;
}

515
void no_satisfied( struct object *obj, struct wait_queue_entry *entry )
516 517 518
{
}

519 520 521 522 523 524
int no_signal( struct object *obj, unsigned int access )
{
    set_error( STATUS_OBJECT_TYPE_MISMATCH );
    return 0;
}

525
struct fd *no_get_fd( struct object *obj )
526
{
527
    set_error( STATUS_OBJECT_TYPE_MISMATCH );
528
    return NULL;
529 530
}

531
unsigned int default_map_access( struct object *obj, unsigned int access )
532
{
533
    return map_access( access, &obj->ops->type->mapping );
534 535
}

536 537 538 539 540
struct security_descriptor *default_get_sd( struct object *obj )
{
    return obj->sd;
}

541 542
int set_sd_defaults_from_token( struct object *obj, const struct security_descriptor *sd,
                                unsigned int set_info, struct token *token )
543 544 545
{
    struct security_descriptor new_sd, *new_sd_ptr;
    int present;
546
    const SID *owner = NULL, *group = NULL;
547
    const ACL *sacl, *dacl;
548
    ACL *replaced_sacl = NULL;
549 550
    char *ptr;

551
    if (!set_info) return 1;
552 553 554

    new_sd.control = sd->control & ~SE_SELF_RELATIVE;

555 556 557
    if (set_info & OWNER_SECURITY_INFORMATION && sd->owner_len)
    {
        owner = sd_get_owner( sd );
558
        new_sd.owner_len = sd->owner_len;
559 560 561 562 563 564
    }
    else if (obj->sd && obj->sd->owner_len)
    {
        owner = sd_get_owner( obj->sd );
        new_sd.owner_len = obj->sd->owner_len;
    }
565
    else if (token)
566
    {
567
        owner = token_get_user( token );
568
        new_sd.owner_len = security_sid_len( owner );
569
    }
570
    else new_sd.owner_len = 0;
571

572 573 574
    if (set_info & GROUP_SECURITY_INFORMATION && sd->group_len)
    {
        group = sd_get_group( sd );
575
        new_sd.group_len = sd->group_len;
576 577 578 579 580 581
    }
    else if (obj->sd && obj->sd->group_len)
    {
        group = sd_get_group( obj->sd );
        new_sd.group_len = obj->sd->group_len;
    }
582
    else if (token)
583
    {
584
        group = token_get_primary_group( token );
585
        new_sd.group_len = security_sid_len( group );
586
    }
587
    else new_sd.group_len = 0;
588 589 590

    sacl = sd_get_sacl( sd, &present );
    if (set_info & SACL_SECURITY_INFORMATION && present)
591 592
    {
        new_sd.control |= SE_SACL_PRESENT;
593
        new_sd.sacl_len = sd->sacl_len;
594
    }
595 596 597 598 599
    else if (set_info & LABEL_SECURITY_INFORMATION && present)
    {
        const ACL *old_sacl = NULL;
        if (obj->sd && obj->sd->control & SE_SACL_PRESENT) old_sacl = sd_get_sacl( obj->sd, &present );
        if (!(replaced_sacl = replace_security_labels( old_sacl, sacl ))) return 0;
600
        new_sd.control |= SE_SACL_PRESENT;
601 602 603
        new_sd.sacl_len = replaced_sacl->AclSize;
        sacl = replaced_sacl;
    }
604 605 606 607 608
    else
    {
        if (obj->sd) sacl = sd_get_sacl( obj->sd, &present );

        if (obj->sd && present)
609 610
        {
            new_sd.control |= SE_SACL_PRESENT;
611
            new_sd.sacl_len = obj->sd->sacl_len;
612
        }
613 614 615 616 617 618
        else
            new_sd.sacl_len = 0;
    }

    dacl = sd_get_dacl( sd, &present );
    if (set_info & DACL_SECURITY_INFORMATION && present)
619 620
    {
        new_sd.control |= SE_DACL_PRESENT;
621
        new_sd.dacl_len = sd->dacl_len;
622
    }
623 624 625 626 627
    else
    {
        if (obj->sd) dacl = sd_get_dacl( obj->sd, &present );

        if (obj->sd && present)
628 629
        {
            new_sd.control |= SE_DACL_PRESENT;
630
            new_sd.dacl_len = obj->sd->dacl_len;
631
        }
632
        else if (token)
633
        {
634
            dacl = token_get_default_dacl( token );
635
            new_sd.control |= SE_DACL_PRESENT;
636 637
            new_sd.dacl_len = dacl->AclSize;
        }
638
        else new_sd.dacl_len = 0;
639 640 641 642
    }

    ptr = mem_alloc( sizeof(new_sd) + new_sd.owner_len + new_sd.group_len +
                     new_sd.sacl_len + new_sd.dacl_len );
643 644 645 646 647
    if (!ptr)
    {
        free( replaced_sacl );
        return 0;
    }
648 649 650 651 652 653 654 655 656 657 658 659
    new_sd_ptr = (struct security_descriptor*)ptr;

    memcpy( ptr, &new_sd, sizeof(new_sd) );
    ptr += sizeof(new_sd);
    memcpy( ptr, owner, new_sd.owner_len );
    ptr += new_sd.owner_len;
    memcpy( ptr, group, new_sd.group_len );
    ptr += new_sd.group_len;
    memcpy( ptr, sacl, new_sd.sacl_len );
    ptr += new_sd.sacl_len;
    memcpy( ptr, dacl, new_sd.dacl_len );

660
    free( replaced_sacl );
661 662
    free( obj->sd );
    obj->sd = new_sd_ptr;
663
    return 1;
664 665
}

666 667 668 669 670 671 672
/** Set the security descriptor using the current primary token for defaults. */
int default_set_sd( struct object *obj, const struct security_descriptor *sd,
                    unsigned int set_info )
{
    return set_sd_defaults_from_token( obj, sd, set_info, current->process->token );
}

673 674 675 676 677
WCHAR *no_get_full_name( struct object *obj, data_size_t *ret_len )
{
    return NULL;
}

678
struct object *no_lookup_name( struct object *obj, struct unicode_str *name,
679
                               unsigned int attr, struct object *root )
680
{
681
    if (!name) set_error( STATUS_OBJECT_TYPE_MISMATCH );
682 683 684
    return NULL;
}

685 686 687 688 689 690
int no_link_name( struct object *obj, struct object_name *name, struct object *parent )
{
    set_error( STATUS_OBJECT_TYPE_MISMATCH );
    return 0;
}

691 692 693 694 695
void default_unlink_name( struct object *obj, struct object_name *name )
{
    list_remove( &name->entry );
}

696 697 698 699 700 701 702
struct object *no_open_file( struct object *obj, unsigned int access, unsigned int sharing,
                             unsigned int options )
{
    set_error( STATUS_OBJECT_TYPE_MISMATCH );
    return NULL;
}

703 704 705 706 707
int no_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
{
    return 1;  /* ok to close */
}

708 709 710
void no_destroy( struct object *obj )
{
}