Exemplo n.º 1
0
static int
compile(blueprint *bp,char const *filename)
{
    struct stat s;

    if (!createparts(bp))
        return 0;

    if (!setnames(bp, ET_EXEC, filename))
        return 0;

    if (!populateparts(bp, ET_EXEC, filename))
        return 0;

    if (!outputelf(bp, outfilename))
    {
        remove(outfilename);
        return 0;
    }

    if (!stat(outfilename, &s))
    {
        if (bp->filetype == ET_EXEC)
            s.st_mode |= S_IXUSR | S_IXGRP | S_IXOTH;

        chmod(outfilename, s.st_mode);
    }

    return 1;
}
Exemplo n.º 2
0
void
rstat(void)
{
	Xfile *f;
	Dir dir;

	chat("stat(fid=%d)...", req->fid);
	f=xfile(req->fid, Asis);
	setnames(&dir, fdata);
	(*f->xf->s->stat)(f, &dir);
	if(chatty)
		showdir(2, &dir);
	rep->nstat = convD2M(&dir, statbuf, sizeof statbuf);
	rep->stat = statbuf;
}
Exemplo n.º 3
0
static void
iwalk(Xfile *f, char *name)
{
	Isofile *ip = f->ptr;
	uint8_t dbuf[256];
	char nbuf[4*Maxname];
	Drec *d = (Drec*)dbuf;
	Dir dir;
	char *p;
	int len, vers, dvers;

	vers = -1;
	if((p = strchr(name, ';')) != nil) {
		len = p-name;
		if(len >= Maxname)
			len = Maxname-1;
		memmove(nbuf, name, len);
		vers = strtoul(p+1, 0, 10);
		name = nbuf;
	}
/*
	len = strlen(name);
	if(len >= Maxname){
		len = Maxname-1;
		if(name != nbuf){
			memmove(nbuf, name, len);
			name = nbuf;
		}
		name[len] = 0;
	}
*/

	chat("%d \"%s\"...", strlen(name), name);
	ip->offset = 0;
	setnames(&dir, nbuf);
	while(getdrec(f, d) >= 0) {
		dvers = rzdir(f->xf, &dir, ip->fmt, d);
		if(casestrcmp(f->xf->isplan9||f->xf->isrock, name, dir.name) != 0)
			continue;
		newdrec(f, d);
		f->qid.path = dir.qid.path;
		f->qid.type = dir.qid.type;
		USED(dvers);
		return;
	}
	USED(vers);
	error(Enonexist);
}
Exemplo n.º 4
0
static int32_t
ireaddir(Xfile *f, uint8_t *buf, int32_t offset, int32_t count)
{
	Isofile *ip = f->ptr;
	Dir d;
	char names[4*Maxname];
	uint8_t dbuf[256];
	Drec *drec = (Drec *)dbuf;
	int n, rcnt;

	if(offset==0){
		ip->offset = 0;
		ip->doffset = 0;
	}else if(offset != ip->doffset)
		error("seek in directory not allowed");

	rcnt = 0;
	setnames(&d, names);
	while(rcnt < count && getdrec(f, drec) >= 0){
		if(drec->namelen == 1){
			if(drec->name[0] == 0)
				continue;
			if(drec->name[0] == 1)
				continue;
		}
		rzdir(f->xf, &d, ip->fmt, drec);
		d.qid.vers = f->qid.vers;
		if((n = convD2M(&d, buf+rcnt, count-rcnt)) <= BIT16SZ){
			ungetdrec(f);
			break;
		}
		rcnt += n;
	}
	ip->doffset += rcnt;
	return rcnt;
}