wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 82f65e067a45bb1599dc9f93bcc29772a3a2c05c
parent 3229e517358fc7de7968b8c252168743853b61af
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Sat, 28 Jan 2006 18:07:04 +0200

now set permissions correctly, time to fill bar2 with X life


Diffstat:
cmd/wmiibar2.c | 44+++++++++++++++++++++++++-------------------
libixp2/ixp.h | 5+++++
2 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/cmd/wmiibar2.c b/cmd/wmiibar2.c @@ -221,6 +221,7 @@ mkqid(Qid *dir, char *wname, Qid *new) { const char *errstr; int type = name_to_type(wname); + unsigned short i = qpath_item(dir->path); if((dir->type != IXP_QTDIR) || (type == -1)) return -1; @@ -244,9 +245,13 @@ mkqid(Qid *dir, char *wname, Qid *new) new->path = mkqpath(Ditem, i); } break; + case Fcolor: + case Fdata: + if(!i || i > nitem) + return -1; default: new->type = IXP_QTFILE; - new->path = mkqpath(type, qpath_item(dir->path)); + new->path = mkqpath(type, i); break; } return 0; @@ -332,7 +337,7 @@ xopen(IXPServer *s, IXPConn *c) static unsigned int mkstat(Stat *stat, Qid *dir, char *name, unsigned long long length, unsigned int mode) { - stat->mode = 0xfff | mode; /* --rwxrwxrwx */ + stat->mode = mode; stat->atime = stat->mtime = time(0); cext_strlcpy(stat->uid, getenv("USER"), sizeof(stat->uid)); cext_strlcpy(stat->gid, getenv("USER"), sizeof(stat->gid)); @@ -362,6 +367,7 @@ xremove(IXPServer *s, IXPConn *c) free(it); return 0; } + s->errstr = "permission denied"; return -1; } @@ -385,21 +391,21 @@ xread(IXPServer *s, IXPConn *c) switch (qpath_type(map->qid.path)) { case Droot: if(align == SOUTH || align == NORTH) - s->fcall.count = mkstat(&stat, &root_qid, "display", 6, 0x0); + s->fcall.count = mkstat(&stat, &root_qid, "display", 6, DMREAD | DMWRITE); else - s->fcall.count = mkstat(&stat, &root_qid, "display", 5, 0x0); /* none */ + s->fcall.count = mkstat(&stat, &root_qid, "display", 5, DMREAD | DMWRITE); /* none */ p = ixp_enc_stat(p, &stat); - s->fcall.count += mkstat(&stat, &root_qid, "font", strlen(font), 0x0); + s->fcall.count += mkstat(&stat, &root_qid, "font", strlen(font), DMREAD | DMWRITE); p = ixp_enc_stat(p, &stat); - s->fcall.count += mkstat(&stat, &root_qid, "new", 0, DMDIR); + s->fcall.count += mkstat(&stat, &root_qid, "new", 0, DMDIR | DMREAD | DMEXEC); p = ixp_enc_stat(p, &stat); - s->fcall.count += mkstat(&stat, &root_qid, "event", 0, 0x0); + s->fcall.count += mkstat(&stat, &root_qid, "event", 0, DMREAD); p = ixp_enc_stat(p, &stat); - s->fcall.count += mkstat(&stat, &root_qid, "default", 0, DMDIR); + s->fcall.count += mkstat(&stat, &root_qid, "default", 0, DMDIR | DMREAD | DMEXEC); p = ixp_enc_stat(p, &stat); for(i = 1; i < nitem; i++) { snprintf(buf, sizeof(buf), "%u", i); - s->fcall.count += mkstat(&stat, &root_qid, buf, 0, DMDIR); + s->fcall.count += mkstat(&stat, &root_qid, buf, 0, DMDIR | DMREAD | DMEXEC); p = ixp_enc_stat(p, &stat); } break; @@ -407,7 +413,7 @@ xread(IXPServer *s, IXPConn *c) if(i > nitem) goto error_xread; if(!i) { - s->fcall.count = mkstat(&stat, &root_qid, "color", 24, 0x0); + s->fcall.count = mkstat(&stat, &root_qid, "color", 24, DMREAD | DMWRITE); p = ixp_enc_stat(p, &stat); break; } @@ -415,9 +421,9 @@ xread(IXPServer *s, IXPConn *c) if(i == nitem) new_item(); Qid dir = {IXP_QTDIR, 0, mkqpath(Ditem, i)}; - s->fcall.count = mkstat(&stat, &dir, "color", 24, 0x0); + s->fcall.count = mkstat(&stat, &dir, "color", 24, DMREAD | DMWRITE); p = ixp_enc_stat(p, &stat); - s->fcall.count += mkstat(&stat, &dir, "data", strlen(item[i]->data), 0x0); + s->fcall.count += mkstat(&stat, &dir, "data", strlen(item[i]->data), DMREAD | DMWRITE); p = ixp_enc_stat(p, &stat); } break; @@ -489,25 +495,25 @@ xstat(IXPServer *s, IXPConn *c) switch (qpath_type(map->qid.path)) { case Droot: case Ditem: - mkstat(&s->fcall.stat, &root_qid, qid_to_name(&map->qid), 0, DMDIR); + mkstat(&s->fcall.stat, &root_qid, qid_to_name(&map->qid), 0, DMDIR | DMREAD | DMEXEC); break; case Fdisplay: if(align == SOUTH || align == NORTH) - mkstat(&s->fcall.stat, &root_qid, qid_to_name(&map->qid), 6, 0x0); + mkstat(&s->fcall.stat, &root_qid, qid_to_name(&map->qid), 6, DMREAD | DMWRITE); else - mkstat(&s->fcall.stat, &root_qid, qid_to_name(&map->qid), 5, 0x0); + mkstat(&s->fcall.stat, &root_qid, qid_to_name(&map->qid), 5, DMREAD | DMWRITE); break; case Fevent: - mkstat(&s->fcall.stat, &root_qid, qid_to_name(&map->qid), 0, 0x0); + mkstat(&s->fcall.stat, &root_qid, qid_to_name(&map->qid), 0, DMREAD); break; case Ffont: - mkstat(&s->fcall.stat, &root_qid, qid_to_name(&map->qid), strlen(font), 0x0); + mkstat(&s->fcall.stat, &root_qid, qid_to_name(&map->qid), strlen(font), DMREAD | DMWRITE); break; case Fdata: - mkstat(&s->fcall.stat, &dir, qid_to_name(&map->qid), strlen(item[i]->data), 0x0); + mkstat(&s->fcall.stat, &dir, qid_to_name(&map->qid), strlen(item[i]->data), DMREAD | DMWRITE); break; case Fcolor: - mkstat(&s->fcall.stat, &dir, qid_to_name(&map->qid), 24, 0x0); + mkstat(&s->fcall.stat, &dir, qid_to_name(&map->qid), 24, DMREAD | DMWRITE); break; default: s->errstr = "invalid stat request"; diff --git a/libixp2/ixp.h b/libixp2/ixp.h @@ -100,6 +100,7 @@ enum { RWSTAT, }; +/* borrowed from libc.h of Plan 9 */ #define DMDIR 0x80000000 /* mode bit for directories */ #define DMAPPEND 0x40000000 /* mode bit for append only files */ #define DMEXCL 0x20000000 /* mode bit for exclusive use files */ @@ -107,6 +108,10 @@ enum { #define DMAUTH 0x08000000 /* mode bit for authentication file */ #define DMTMP 0x04000000 /* mode bit for non-backed-up file */ +#define DMREAD 0x4<<6 /* mode bit for read permission */ +#define DMWRITE 0x2<<6 /* mode bit for write permission */ +#define DMEXEC 0x1<<6 /* mode bit for execute permission */ + /* modes */ enum { IXP_OREAD = 0x00,