From fbe8b33b7b8d676e99de8d46b200cd05abf6ea00 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 2 Feb 1994 21:40:03 +0000 Subject: Formerly protid-make.c.~2~ --- libdiskfs/protid-make.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'libdiskfs') diff --git a/libdiskfs/protid-make.c b/libdiskfs/protid-make.c index 13767ae7..daa80749 100644 --- a/libdiskfs/protid-make.c +++ b/libdiskfs/protid-make.c @@ -30,3 +30,44 @@ diskfs_start_protid (struct peropen *po) cred->mapped = 0; return cred; } + +/* Finish building protid CRED started with diskfs_start_protid; + the uid set is UID (length NUIDS); the gid set is GID (length NGIDS). */ +void +diskfs_finish_protid (struct protid *cred, uid_t *uids, int nuids, + gid_t *gids, int nguds) +{ + if (!uids) + nuids = 1; + if (!gids) + ngids = 1; + + cred->uids = malloc (nuids * sizeof (uid_t)); + cred->gids = malloc (ngids * sizeof (uid_t)); + cred->nuids = nuids; + cred->ngids = ngids; + + if (uids) + bcopy (uids, cred->uids, nuids * sizeof (uid_t)); + else + *cred->uids = 0; + + if (gids) + bcopy (gids, cred->gids, ngids * sizeof (uid_t)); + else + *cred->gids = 0; +} + +/* Create and return a protid for an existing peropen. The uid set is + UID (length NUIDS); the gid set is GID (length NGIDS). The node + PO->np must be locked. */ +struct protid * +diskfs_make_protid (struct peropen *cred, uid_t *uids, int nuids, + uid_t *gids, int ngids) +{ + struct protid *cred = diskfs_start_protid (cred); + diskfs_finish_protid (cred, uids, nuids, gids, ngids); + return cred; +} + + -- cgit v1.2.3