hgfs: honor x-bit in manifest

This commit is contained in:
cinap_lenrek 2011-06-27 11:27:32 +00:00
parent 2b5a7cebc2
commit 0f61b5506c
3 changed files with 17 additions and 6 deletions

View file

@ -51,6 +51,8 @@ struct Revnode
Revnode *up;
Revnode *next;
Revnode *down;
char mode;
};
struct Revinfo

View file

@ -219,6 +219,8 @@ fsmkdir(Dir *d, int level, void *aux)
case Qtree:
nd = aux;
d->name = estrdup9p(nd->name);
if(nd->mode == 'x')
d->mode |= 0111;
if(nd->hash){
char path[MAXPATH];
Revlog rl;

View file

@ -44,7 +44,7 @@ nodepath(char *s, char *e, Revnode *nd)
}
static void
addnode(Revnode *d, char *path, uchar *hash)
addnode(Revnode *d, char *path, uchar *hash, char mode)
{
char *slash, *x;
Revnode *c, *p;
@ -61,10 +61,13 @@ addnode(Revnode *d, char *path, uchar *hash)
c->path = 1;
x = (char*)&c[1];
if(!slash){
c->mode = mode;
memmove(c->hash = (uchar*)x, hash, HASHSZ);
x += HASHSZ;
} else
}else{
c->mode = 0;
c->hash = nil;
}
strcpy(c->name = x, path);
c->up = d;
c->down = nil;
@ -117,7 +120,7 @@ hashstr(char *s)
static int
loadmanifest(Revnode *root, int fd, Hashstr **ht, int nh)
{
char buf[BUFSZ], *p, *e;
char buf[BUFSZ], *p, *e, *x;
uchar hash[HASHSZ];
int n;
@ -128,15 +131,19 @@ loadmanifest(Revnode *root, int fd, Hashstr **ht, int nh)
while((p > buf) && (e = memchr(buf, '\n', p - buf))){
*e++ = 0;
strhash(buf + strlen(buf) + 1, hash);
x = buf;
x += strlen(x) + 1;
strhash(x, hash);
x += HASHSZ*2;
if(ht == nil)
addnode(root, buf, hash);
addnode(root, buf, hash, *x);
else {
Hashstr *he;
for(he = ht[hashstr(buf) % nh]; he; he = he->next){
if(strcmp(he->str, buf) == 0){
addnode(root, buf, hash);
addnode(root, buf, hash, *x);
break;
}
}