commit bbbe27bedceefa3be37c584149f7526821187296
parent 538384f55f37e588a78f41bc45136fed68780fc5
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Mon, 6 Mar 2006 20:15:43 +0100
implemented 'wmiir append' (ie can be used to append tags)
Diffstat:
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -515,7 +515,8 @@ xopen(IXPConn *c, Fcall *fcall)
if(!m)
return Enofid;
- if(!(fcall->mode | IXP_OREAD) && !(fcall->mode | IXP_OWRITE))
+ if(!(fcall->mode | IXP_OREAD)
+ && !((fcall->mode | IXP_OWRITE) || (fcall->mode | IXP_OAPPEND)))
return Enomode;
fcall->id = ROPEN;
fcall->qid = m->qid;
@@ -1098,10 +1099,16 @@ xwrite(IXPConn *c, Fcall *fcall)
break;
case FsFtags:
f = tag[i1]->area[i2]->frame[i3];
- if(fcall->count > sizeof(f->client->tags))
+ if(fcall->mode | IXP_OAPPEND) {
+ cext_strlcat(f->client->tags, " ", sizeof(f->client->tags));
+ i = strlen(f->client->tags);
+ }
+ else
+ i = 0;
+ if(fcall->count + i > sizeof(f->client->tags))
return "tags value too long";
- memcpy(f->client->tags, fcall->data, fcall->count);
- f->client->tags[fcall->count] = 0;
+ memcpy(f->client->tags + i, fcall->data, fcall->count);
+ f->client->tags[fcall->count + i] = 0;
update_ctags();
break;
case FsFgeom:
diff --git a/cmd/wmiir.c b/cmd/wmiir.c
@@ -20,7 +20,7 @@ static char version[] = "wmiir - " VERSION ", (C)opyright MMIV-MMVI Anselm R. Ga
static void
usage()
{
- fprintf(stderr, "%s", "usage: wmiir [-a <address>] [-v] create | read | write | remove <file>\n");
+ fprintf(stderr, "%s", "usage: wmiir [-a <address>] [-v] append | create | read | remove | write <file>\n");
exit(1);
}
@@ -68,12 +68,11 @@ xcreate(char *file)
}
static int
-xwrite(char *file)
+xwrite(char *file, unsigned char mode)
{
-
/* open */
unsigned int fid = c.root_fid << 2;
- if(ixp_client_open(&c, fid, file, IXP_OWRITE) == -1) {
+ if(ixp_client_open(&c, fid, file, mode) == -1) {
fprintf(stderr, "wmiir: cannot open file '%s': %s\n", file, c.errstr);
return -1;
}
@@ -264,14 +263,16 @@ main(int argc, char *argv[])
exit(1);
}
- if(!strncmp(cmd, "create", 7))
+ if(!strncmp(cmd, "append", 7))
+ ret = xwrite(file, IXP_OAPPEND);
+ else if(!strncmp(cmd, "create", 7))
ret = xcreate(file);
- else if(!strncmp(cmd, "write", 6))
- ret = xwrite(file);
else if(!strncmp(cmd, "read", 5))
ret = xread(file);
else if(!strncmp(cmd, "remove", 7))
ret = xremove(file);
+ else if(!strncmp(cmd, "write", 6))
+ ret = xwrite(file, IXP_OWRITE);
else
usage();