static struct semaphore *create_semaphore( struct directory *root, const struct unicode_str *name, unsigned int attr, unsigned int initial, unsigned int max, const struct security_descriptor *sd ) { struct semaphore *sem; if (!max || (initial > max)) { set_error( STATUS_INVALID_PARAMETER ); return NULL; } if ((sem = create_named_object_dir( root, name, attr, &semaphore_ops ))) { if (get_error() != STATUS_OBJECT_NAME_EXISTS) { /* initialize it if it didn't already exist */ sem->count = initial; sem->max = max; if (sd) default_set_sd( &sem->obj, sd, OWNER_SECURITY_INFORMATION| GROUP_SECURITY_INFORMATION| DACL_SECURITY_INFORMATION| SACL_SECURITY_INFORMATION ); } } return sem; }
struct symlink *create_symlink( struct directory *root, const struct unicode_str *name, unsigned int attr, const struct unicode_str *target, const struct security_descriptor *sd ) { struct symlink *symlink; if (!target->len) { set_error( STATUS_INVALID_PARAMETER ); return NULL; } if ((symlink = create_named_object_dir( root, name, attr, &symlink_ops )) && (get_error() != STATUS_OBJECT_NAME_EXISTS)) { if ((symlink->target = memdup( target->str, target->len ))) { symlink->len = target->len; if (sd) default_set_sd( &symlink->obj, sd, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION ); } else { release_object( symlink ); symlink = NULL; } } return symlink; }
struct keyed_event *create_keyed_event( struct directory *root, const struct unicode_str *name, unsigned int attr, const struct security_descriptor *sd ) { struct keyed_event *event; if ((event = create_named_object_dir( root, name, attr, &keyed_event_ops ))) { if (get_error() != STATUS_OBJECT_NAME_EXISTS) { /* initialize it if it didn't already exist */ if (sd) default_set_sd( &event->obj, sd, OWNER_SECURITY_INFORMATION| GROUP_SECURITY_INFORMATION| DACL_SECURITY_INFORMATION| SACL_SECURITY_INFORMATION ); } } return event; }
static struct mutex *create_mutex( struct directory *root, const struct unicode_str *name, unsigned int attr, int owned, const struct security_descriptor *sd ) { struct mutex *mutex; if ((mutex = create_named_object_dir( root, name, attr, &mutex_ops ))) { if (get_error() != STATUS_OBJECT_NAME_EXISTS) { /* initialize it if it didn't already exist */ mutex->count = 0; mutex->owner = NULL; mutex->abandoned = 0; if (owned) do_grab( mutex, current ); if (sd) default_set_sd( &mutex->obj, sd, OWNER_SECURITY_INFORMATION| GROUP_SECURITY_INFORMATION| DACL_SECURITY_INFORMATION| SACL_SECURITY_INFORMATION ); } } return mutex; }