summaryrefslogtreecommitdiff
path: root/sys/src/cmd/hgfs/tree.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-07-01 08:31:29 +0200
committercinap_lenrek <cinap_lenrek@localhost>2011-07-01 08:31:29 +0200
commit400e1b3643881c9c26c1824c370393f1d41ae7c5 (patch)
treebf266083d48f47d81bbf5533fec7c3a05ddcb928 /sys/src/cmd/hgfs/tree.c
parent2f59a5d3921d7737f06a0d3c7d35af86191ab737 (diff)
hgfs: make qid generation machine independent
Diffstat (limited to 'sys/src/cmd/hgfs/tree.c')
-rw-r--r--sys/src/cmd/hgfs/tree.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/src/cmd/hgfs/tree.c b/sys/src/cmd/hgfs/tree.c
index 517d7ad54..bb4fcb40c 100644
--- a/sys/src/cmd/hgfs/tree.c
+++ b/sys/src/cmd/hgfs/tree.c
@@ -5,7 +5,7 @@
#include "fns.h"
char*
-nodepath(char *s, char *e, Revnode *nd)
+nodepath(char *s, char *e, Revnode *nd, int mangle)
{
static char *frogs[] = {
"con", "prn", "aux", "nul",
@@ -18,9 +18,11 @@ nodepath(char *s, char *e, Revnode *nd)
if(nd == nil || nd->name == nil)
return s;
- s = seprint(nodepath(s, e, nd->up), e, "/");
-
+ s = seprint(nodepath(s, e, nd->up, mangle), e, "/");
p = nd->name;
+ if(!mangle)
+ return seprint(s, e, "%s", p);
+
for(i=0; i<nelem(frogs); i++){
l = strlen(frogs[i]);
if((strncmp(frogs[i], p, l) == 0) && (p[l] == 0 || p[l] == '.'))
@@ -54,7 +56,7 @@ mknode(char *name, uchar *hash, char mode)
memset(d, 0, sizeof(*d));
s = (char*)&d[1];
if(hash){
- d->path = *((uvlong*)hash);
+ d->path = hash2qid(hash);
memmove(d->hash = (uchar*)s, hash, HASHSZ);
s += HASHSZ;
}else
@@ -88,10 +90,9 @@ addnode(Revnode *d, char *path, uchar *hash, char mode)
c->next = d->down;
d->down = c;
}
- if(c->hash){
+ if(!slash){
p = c;
- p->path = *((uvlong*)c->hash);
- while(d->up){
+ while(d){
d->path += p->path;
p = d;
d = d->up;
@@ -142,7 +143,7 @@ loadmanifest(Revnode *root, int fd, Hashstr **ht, int nh)
x = buf;
x += strlen(x) + 1;
- strhash(x, hash);
+ hex2hash(x, hash);
x += HASHSZ*2;
if(ht == nil)