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 *up;
Revnode *next; Revnode *next;
Revnode *down; Revnode *down;
char mode;
}; };
struct Revinfo struct Revinfo

View file

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

View file

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