Skip to content

Commit

Permalink
beginnings of key system
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbjohnson4224 committed Jan 30, 2012
1 parent d5a5f82 commit 561a089
Show file tree
Hide file tree
Showing 29 changed files with 254 additions and 73 deletions.
6 changes: 3 additions & 3 deletions Makefile
@@ -1,11 +1,11 @@
BUILDDIR=$(PWD)

LIB_DIRS = libc dl librdi ports/lua ports/freetype libtoolkit
LIB_DIRS = libc dl librdi ports/lua ports/freetype

DRIVERS := $(shell find driver -mindepth 1 -maxdepth 1)
DAEMONS := $(shell find daemon -mindepth 1 -maxdepth 1)
DAEMONS := daemon/init
UTILS := $(shell find util -mindepth 1 -maxdepth 1)
APPS := $(shell find apps -mindepth 1 -maxdepth 1)
APPS := apps/calico

BIN_DIRS = kernel fish
BIN_DIRS += $(DRIVERS) $(DAEMONS) $(UTILS) $(APPS)
Expand Down
2 changes: 1 addition & 1 deletion driver/biterm/main.c
Expand Up @@ -145,7 +145,7 @@ int main(int argc, char **argv) {
return 1;
}

ret = rcall(wmanager, "createwindow");
ret = rcall(wmanager, 0, "createwindow");
kbd_dev = fb_dev = ator(ret);
free(ret);

Expand Down
4 changes: 2 additions & 2 deletions libc/graph/fb_cons.c
Expand Up @@ -46,7 +46,7 @@ struct fb *fb_cons(uint64_t rp) {
fb->flags = 0;

// check video mode
mode = rcall(rp, "getmode");
mode = rcall(rp, 0, "getmode");

if (!mode) {
close(fb->fd);
Expand Down Expand Up @@ -86,6 +86,6 @@ struct fb *fb_createwindow() {
return NULL;
}

ret = rcall(wmanager, "createwindow");
ret = rcall(wmanager, 0, "createwindow");
return fb_cons(ator(ret));
}
2 changes: 1 addition & 1 deletion libc/graph/fb_flip.c
Expand Up @@ -46,7 +46,7 @@ int fb_flip(struct fb *fb) {

if (fb->flags & FB_SHARED) {
// shared: just sync
ret = rcall(fd_rp(fb->fd), "syncrect %d %d %d %d", fb->minx, fb->miny,
ret = rcall(fd_rp(fb->fd), 0, "syncrect %d %d %d %d", fb->minx, fb->miny,
fb->maxx - fb->minx, fb->maxy - fb->miny);
if (!ret || !strcmp(ret, "")) {
mutex_free(&fb->mutex);
Expand Down
2 changes: 1 addition & 1 deletion libc/graph/fb_setmode.c
Expand Up @@ -43,7 +43,7 @@ int fb_setmode(struct fb *fb, int xdim, int ydim) {
}

sprintf(args, "setmode %d %d 32", xdim, ydim);
ret = rcall(fb->rp, args);
ret = rcall(fb->rp, 0, args);

if (!ret) {
return 1;
Expand Down
53 changes: 27 additions & 26 deletions libc/inc/rho/ipc.h
Expand Up @@ -25,34 +25,35 @@
/* action numbers ***********************************************************/

// kernel events and signals
#define ACTION_QUIT 0
#define ACTION_TERM 1
#define ACTION_ABORT 2
#define ACTION_KILL 3
#define ACTION_STOP 4
#define ACTION_CONT 5
#define ACTION_TRAP 6
#define ACTION_INT 7
#define ACTION_IRQ 8
#define ACTION_ALARM 9
#define ACTION_CHILD 10
#define ACTION_FLOAT 11
#define ACTION_PAGE 12
#define ACTION_ILL 13
#define ACTION_USER1 14
#define ACTION_USER2 15
#define ACTION_QUIT 0
#define ACTION_TERM 1
#define ACTION_ABORT 2
#define ACTION_KILL 3
#define ACTION_STOP 4
#define ACTION_CONT 5
#define ACTION_TRAP 6
#define ACTION_INT 7
#define ACTION_IRQ 8
#define ACTION_ALARM 9
#define ACTION_CHILD 10
#define ACTION_FLOAT 11
#define ACTION_PAGE 12
#define ACTION_ILL 13
#define ACTION_USER1 14
#define ACTION_USER2 15

// I/O and similar
#define ACTION_REPLY 16
#define ACTION_READ 17
#define ACTION_WRITE 18
#define ACTION_SYNC 19
#define ACTION_RESET 20
#define ACTION_SHARE 21
#define ACTION_RCALL 22
#define ACTION_EVENT 23
#define ACTION_CLOSE 24
#define ACTION_MMAP 25
#define ACTION_REPLY 16
#define ACTION_READ 17
#define ACTION_WRITE 18
#define ACTION_SYNC 19
#define ACTION_RESET 20
#define ACTION_SHARE 21
#define ACTION_RCALL 22
#define ACTION_EVENT 23
#define ACTION_CLOSE 24
#define ACTION_MMAP 25
#define ACTION_FINISH 26

/* message structure ********************************************************/

Expand Down
3 changes: 3 additions & 0 deletions libc/inc/rho/types.h
Expand Up @@ -22,6 +22,9 @@
// resource pointer type
typedef uint64_t rp_t;

// resource action key type
typedef uint64_t rk_t;

// file offset type
typedef uint64_t off_t;

Expand Down
96 changes: 94 additions & 2 deletions libc/inc/rhombus.h
Expand Up @@ -140,11 +140,102 @@ int close(int fd);
int dup (int fd);
int dup2 (int fd, int newfd);

/*****************************************************************************
* Resource Action Classes
*
* Resources have a multitude of different actions that can be performed on
* them with both the builtin I/O messages (read, write, mmap, sync, reset)
* and with the open-ended rcall messages. Different drivers and resources
* within those drivers may expose different sets of actions. To impose some
* order on this, actions are divided into "action classes". Whether or not a
* process can perform an action is dependent on that action's class.
*
* The eight action classes are as follows:
*
* 0 - AC_NULL
*
* The default action class. Actions of class AC_NULL are not restricted by
* the native access control system, although they may implement their own
* based on source and key information.
*
* Example actions: find, ping, name, stat, get-key, get-access, get-ac
*
* 1 - AC_READ
*
* The action class for actions that read data from a resource. If the data
* is not potentially sensitive (like whether the resource exists or not)
* then the AC_NULL class would be used instead.
*
* Example actions: read, size, list, get-link
*
* 2 - AC_WRITE
*
* The action class for actions that write data to a resource.
*
* Example actions: write, sync, reset, finish, set-link
*
* 3 - AC_ALTER
*
* The action class for actions that alter the directory structure or the
* existence of resources, but not for those that change the permissions of
* existing resources.
*
* Example actions: create, delete, link, unlink,
*
* 4 - AC_ADMIN
*
* The action class for actions that modify the permissions of existing
* resources.
*
* Example actions: set-access
*
* 5 - AC_EVENT
*
* The action class for actions that change the event subscriber list of a
* resource.
*
* Example actions: listen, un-listen
*
* 6 - AC_LOCK
*
* The action class for actions that create both advisory and mandatory read
* and write locks on a resource.
*
* Example actions: lock, unlock
*
* 7 - AC_ROOT
*
* The action class for administrative actions pertaining to the driver
* itself. Generally very driver-specific.
*
* Example actions: power-down, hard-reset
*/

#define AC_NULL 0
#define AC_READ 1
#define AC_WRITE 2
#define AC_ALTER 3
#define AC_ADMIN 4
#define AC_EVENT 5
#define AC_LOCK 6
#define AC_ROOT 7

/*****************************************************************************
* Resource Action Keys
*
* Every resource has a set of "action keys", one for each action class that
* may be performed on it. These action keys are used to authenticate actions
* performed on a resource.
*/

rk_t rp_getkey (rp_t rp, int action);
int rp_getkeys(rp_t rp, rk_t keys[8]);

/*****************************************************************************
* Resource Access Control Lists
*
* Every resource has a set of access bitmaps that determine which processes
* and users can perform which functions on that resource.
* and users can perform which actions on that resource.
*
* The following flags correspond to bits that may be set in the access
* bitmap. Permissions can be assigned on a per-user basis.
Expand Down Expand Up @@ -195,7 +286,7 @@ int rp_admin (rp_t rp, uint32_t user, int access);
*/

// perform an rcall
char *rcall (rp_t rp, const char *fmt, ...);
char *rcall (rp_t rp, rk_t key, const char *fmt, ...);
char *frcall(int fd, const char *fmt, ...);

// root rcall hook format
Expand Down Expand Up @@ -258,6 +349,7 @@ int fevent(int fd, const char *value);
* find
* get-access
* set-access
* get-key
*
* "event" - is capable of (but not guaranteed to be) emitting events.
*
Expand Down
2 changes: 1 addition & 1 deletion libc/init/init.c
Expand Up @@ -174,7 +174,7 @@ void __libc_init(int (*_main)(int, char**)) {
when(ACTION_REPLY, NULL);
when(ACTION_READ, __reject);
when(ACTION_WRITE, __reject);
when(ACTION_SYNC, __reject);
when(ACTION_SYNC, __reject);
when(ACTION_RESET, __reject);
when(ACTION_SHARE, __reject);
when(ACTION_RCALL, __rcall_handler);
Expand Down
4 changes: 2 additions & 2 deletions libc/natio/fs_find.c
Expand Up @@ -79,10 +79,10 @@ static rp_t __fs_find(const char *path, int linkmax, int link) {
if (!path_s) return RP_NULL;

if (link) {
reply = rcall(root, "find -L %s", path_s);
reply = rcall(root, 0, "find -L %s", path_s);
}
else {
reply = rcall(root, "find %s", path_s);
reply = rcall(root, 0, "find %s", path_s);
}

free(path_s);
Expand Down
4 changes: 2 additions & 2 deletions libc/natio/fs_link.c
Expand Up @@ -60,7 +60,7 @@ int rp_ulink(rp_t dir, const char *name) {
return 1;
}

reply = rcall(dir, "unlink %s", name);
reply = rcall(dir, 0, "unlink %s", name);

if (iserror(reply)) {
errno = geterror(reply);
Expand Down Expand Up @@ -103,7 +103,7 @@ int rp_link(uint64_t dir, const char *name, uint64_t link) {
return 1;
}

reply = rcall(dir, "link %s %r", name, link);
reply = rcall(dir, 0, "link %s %r", name, link);

if (iserror(reply)) {
errno = geterror(reply);
Expand Down
2 changes: 1 addition & 1 deletion libc/natio/rp_cons.c
Expand Up @@ -33,7 +33,7 @@ rp_t rp_cons(rp_t driver, const char *type) {
rp_t rp;
char *reply;

reply = rcall(RP_PID(driver), "cons %s", type);
reply = rcall(RP_PID(driver), 0, "cons %s", type);

if (!reply) {
errno = ENOSYS;
Expand Down
2 changes: 1 addition & 1 deletion libc/natio/rp_list.c
Expand Up @@ -31,7 +31,7 @@
char *rp_list(rp_t dir) {
char *reply;

reply = rcall(dir, "list");
reply = rcall(dir, 0, "list");

if (!reply) {
return strdup("");
Expand Down
2 changes: 1 addition & 1 deletion libc/natio/rp_size.c
Expand Up @@ -38,7 +38,7 @@ off_t rp_size(rp_t file) {
return 0;
}

reply = rcall(file, "size");
reply = rcall(file, 0, "size");

if (!reply) {
errno = ENOSYS;
Expand Down
2 changes: 1 addition & 1 deletion libc/natio/rp_slink.c
Expand Up @@ -31,7 +31,7 @@
int rp_slink(uint64_t rp, const char *link) {
char *reply;

reply = rcall(rp, "set-link %s", link);
reply = rcall(rp, 0, "set-link %s", link);

if (iserror(reply)) {
errno = geterror(reply);
Expand Down
4 changes: 2 additions & 2 deletions libc/rhombus/contab.c
Expand Up @@ -224,10 +224,10 @@ static int _rp_connect(rp_t rp, int status) {
char *reply;

if (status) {
reply = rcall(rp, "open %d", status);
reply = rcall(rp, 0, "open %d", status);
}
else {
reply = rcall(rp, "close");
reply = rcall(rp, 0, "close");
}

if (iserror(reply)) {
Expand Down

0 comments on commit 561a089

Please sign in to comment.