Introduce falloc_caps() to create descriptors with capabilties in place.
falloc_noinstall() followed by finstall() allows you to create and install file descriptors with custom capabilities. Add falloc_caps() that can do both of these actions in one go. This will be used by CloudABI to create pipes with custom capabilities. Reviewed by: mjg
This commit is contained in:
parent
64b986d16d
commit
4072f1cf76
@ -1707,7 +1707,8 @@ fdallocn(struct thread *td, int minfd, int *fds, int n)
|
||||
* release the FILEDESC lock.
|
||||
*/
|
||||
int
|
||||
falloc(struct thread *td, struct file **resultfp, int *resultfd, int flags)
|
||||
falloc_caps(struct thread *td, struct file **resultfp, int *resultfd, int flags,
|
||||
struct filecaps *fcaps)
|
||||
{
|
||||
struct file *fp;
|
||||
int error, fd;
|
||||
@ -1716,7 +1717,7 @@ falloc(struct thread *td, struct file **resultfp, int *resultfd, int flags)
|
||||
if (error)
|
||||
return (error); /* no reference held on error */
|
||||
|
||||
error = finstall(td, fp, &fd, flags, NULL);
|
||||
error = finstall(td, fp, &fd, flags, fcaps);
|
||||
if (error) {
|
||||
fdrop(fp, td); /* one reference (fp only) */
|
||||
return (error);
|
||||
|
@ -146,6 +146,10 @@ enum {
|
||||
/* Flags for kern_dup(). */
|
||||
#define FDDUP_FLAG_CLOEXEC 0x1 /* Atomically set UF_EXCLOSE. */
|
||||
|
||||
/* For backward compatibility. */
|
||||
#define falloc(td, resultfp, resultfd, flags) \
|
||||
falloc_caps(td, resultfp, resultfd, flags, NULL)
|
||||
|
||||
struct thread;
|
||||
|
||||
void filecaps_init(struct filecaps *fcaps);
|
||||
@ -156,8 +160,8 @@ void filecaps_free(struct filecaps *fcaps);
|
||||
int closef(struct file *fp, struct thread *td);
|
||||
int dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode,
|
||||
int openerror, int *indxp);
|
||||
int falloc(struct thread *td, struct file **resultfp, int *resultfd,
|
||||
int flags);
|
||||
int falloc_caps(struct thread *td, struct file **resultfp, int *resultfd,
|
||||
int flags, struct filecaps *fcaps);
|
||||
int falloc_noinstall(struct thread *td, struct file **resultfp);
|
||||
void _finstall(struct filedesc *fdp, struct file *fp, int fd, int flags,
|
||||
struct filecaps *fcaps);
|
||||
|
Loading…
Reference in New Issue
Block a user