| Current File : //usr/include/project.h |
/*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _PROJECT_H
#define _PROJECT_H
#include <stdio.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Flags for setproject*() functions. These must not collide with other flags
* that can affect setproject*() behavior. Currently, these are TASK_PROJ_MASK
* and TASK_PROJ_PURGE.
*/
#define PROJ_FORCE_NEWTASK 0x0100
#define PROJ_BIND_DEFAULT_POOL 0x0200
/* private flag. Maintained for setproject() to return kvarray offset. */
#define PROJ_RET_KV_OFFSET 0x0400
/* private flag. Used by newtask(1) to indicate that it's a setuid program. */
#define PROJ_SETUID 0x0800
/*
* private flag. Used by newtask(1) to verify the owner of the target process is
* a member of the project. This check is skipped when the caller is the root.
*/
#define PROJ_CHECK_PROJ_MEMBER 0x1000
#define PROJF_PATH "/etc/project" /* pathname of the "project" file */
#define PROJNAME_MAX 64 /* maximum project name size */
#define PROJECT_BUFSZ 4096 /* default buffer size */
/*
* setproject*() error return values. All of them must be negative because
* positive return value for setproject() indicates the offset of failed kvarray
* offset.
*/
#define SETPROJ_ERR_TASK (-1) /* error creating new task */
#define SETPROJ_ERR_POOL (-2) /* error binding to pool */
#define SETPROJ_ERR_MCB (-3) /* error binding to mcb */
#define SETPROJ_ERR_RCTL (-4) /* error setting rctl */
struct project {
char *pj_name; /* name of the project */
projid_t pj_projid; /* numerical project id */
char *pj_comment; /* project description */
char **pj_users; /* vector of pointers to project user names */
char **pj_groups; /* vector of pointers to project group names */
char *pj_attr; /* project attributes string */
};
extern void setprojent(void);
extern void endprojent(void);
extern struct project *getprojent(struct project *, void *, size_t);
extern struct project *getprojbyname(const char *,
struct project *, void *, size_t);
extern struct project *getprojbyid(projid_t, struct project *, void *, size_t);
extern struct project *getdefaultproj(const char *,
struct project *, void *, size_t);
extern struct project *fgetprojent(FILE *, struct project *, void *, size_t);
extern int inproj(const char *, const char *, void *, size_t);
extern projid_t getprojidbyname(const char *);
extern projid_t getprojid(void);
extern long getnproc_prjid(projid_t);
extern int project_walk(int (*)(projid_t, void *), void *);
/* various functions for setting project. */
extern int setproject(const char *, const char *, uint_t);
/* following functions for setting projects are volatile. */
extern int setproject_byname(const char *, uint_t, char **);
extern int setproject_byname_pid(const char *, pid_t, uint_t, char **);
extern int setproject_byprojent(struct project *, uint_t, char **);
extern int setproject_byprojent_pid(struct project *, pid_t, uint_t, char **);
extern int project_update_byname(const char *, uint_t, char **);
extern int project_update_byprojent(struct project *, uint_t, char **);
extern void project_msgs_free(char *);
/* End of the list of volatile functions. */
#ifdef __cplusplus
}
#endif
#endif /* _PROJECT_H */