vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

local.c.ed (1224B)


      1 /^connectlocalkfs/+/^$/i
      2 	char buf[512];
      3 	char *argv0;
      4 	char *cmd = "/boot/bzfs";
      5 .
      6 /stat/;/^$/ d
      7 /dirfstat/ i
      8 	/* can do the check in 9vx -- kfs is kfs */
      9 	memset(buf, 0, sizeof buf);
     10 	pread(fd, buf, 512, 0);
     11 	if(memcmp(buf+256, "kfs wren device\n", 16) == 0)
     12 		cmd = "/boot/kfs";
     13 	else{
     14 		/* if an iso image, use 9660srv */
     15 		pread(fd, buf, 512, 17*0x800);
     16 		if(memcmp(buf, "\0CD001", 6) == 0)
     17 			cmd = "/boot/9660srv";
     18 	}
     19 	/* argv0 is basename(cmd) */
     20 	argv0 = strrchr(cmd, '/') + 1;
     21 	if(stat(cmd, statbuf, sizeof statbuf) < 0)
     22 		return -1;
     23 
     24 .
     25 /print\("kfs\.\.\."\)/ s/"kfs\.\.\."/"%s...", argv0/
     26 /"kfs"/ s/"kfs"/argv0/
     27 /exec/ s;"/boot/kfs";cmd;g
     28 g/fatal\(.*kfs.*\)/ s/ (for )?kfs//
     29 /fatal\("open \/net\/ipifc\/clone for loopback"\)/s,[^	],// &,
     30 a
     31 			return;
     32 .
     33 /^connectlocal\(void\)/-1i
     34 int
     35 connectlocalroot(void)
     36 {
     37 	int fd;
     38 	char buf[1024];
     39 
     40 	snprint(buf, sizeof buf, "%s/%s/bin/rc", disk, cputype);
     41 	if(stat(buf, statbuf, sizeof statbuf) < 0)
     42 		return -1;
     43 	localroot = disk;
     44 
     45 	/* create working fd for /srv/boot */
     46 	fd = open("#~/mntloop", ORDWR);
     47 	if(fd < 0){
     48 		print("open #~/mntloop: %r\n");
     49 		return -1;
     50 	}
     51 	write(fd, disk, strlen(disk));
     52 	return fd;
     53 }
     54 
     55 .
     56 /fd = connectlocal/i
     57 	if((fd = connectlocalroot()) < 0)
     58 .