Content-type: text/html
cc -mt [ flag ... ] file ... -ldoor [ library ... ] #include <door.h> int door_create(void (*server_procedure) (void *cookie, char *argp, size_t arg_size, door_desc_t *dp, uint_t n_desc), void *cookie, uint_t attributes);
The door_create() function creates a door descriptor that describes the procedure specified by the function server_procedure. The data item, cookie, is associated with the door descriptor, and is passed as an argument to the invoked function server_procedure during door_call(3DOOR) invocations. Other arguments passed to server_procedure from an associated door_call() are placed on the stack and include argp and dp. The argp argument points to arg_size bytes of data and the dp argument points to n_desc door_desc_t structures. The attributes argument specifies attributes associated with the newly created door. Valid values for attributes are constructed by OR-ing one or more of the following values:
DOOR_UNREF
DOOR_UNREF_MULTI
DOOR_PRIVATE
DOOR_REFUSE_DESC
The descriptor returned from door_create() will be marked as close on exec (FD_CLOEXEC). Information about a door is available for all clients of a door using door_info(3DOOR). Applications concerned with security should not place secure information in door data that is accessible by door_info(). In particular, secure data should not be stored in the data item cookie.
By default, additional threads are created as needed to handle concurrent door_call(3DOOR) invocations. See door_server_create(3DOOR) for information on how to change this behavior.
A process can advertise a door in the file system name space using fattach(3C).
Upon successful completion, door_create() returns a non-negative value. Otherwise, door_create returns -1 and sets errno to indicate the error.
The door_create() function will fail if:
EINVAL
EMFILE
Example 1 Create a door and use fattach() to advertise the door in the file system namespace.
The following example creates a door and uses fattach() to advertise the door in the file system namespace.
void server(void *cookie, char *argp, size_t arg_size, door_desc_t *dp, uint_t n_desc) { door_return(NULL, 0, NULL, 0); /* NOTREACHED */ } int main(int argc, char *argv[]) { int did; struct stat buf; if ((did = door_create(server, 0, 0)) < 0) { perror("door_create"); exit(1); } /* make sure file system location exists */ if (stat("/tmp/door", &buf) < 0) { int newfd; if ((newfd = creat("/tmp/door", 0444)) < 0) { perror("creat"); exit(1); } (void) close(newfd); } /* make sure nothing else is attached */ (void) fdetach("/tmp/door"); /* attach to file system */ if (fattach(did, "/tmp/door") < 0) { perror("fattach"); exit(2); } [...] }
See attributes(5) for descriptions of the following attributes:
|
door_bind(3DOOR), door_call(3DOOR), door_info(3DOOR), door_revoke(3DOOR), door_server_create(3DOOR), fattach(3C), libdoor(3LIB), attributes(5)