plan 9 kernel history: overview | file list | diff list

1991/1011/power/boot.c (diff list | history)

1991/0820/sys/src/9/power/boot.c:46,511991/1011/sys/src/9/power/boot.c:46,53 (short | long | prev | next)
1990/1127    
int	nonetdial(char *); 
int	bitdial(char *); 
1991/0304    
int	preamble(int); 
1991/1011    
void	srvcreate(char*, int); 
void	settime(void); 
1990/0227    
 
1990/0427    
/* 
 *  usage: 9b [-a] [server] [file] 
1991/0820/sys/src/9/power/boot.c:366,3731991/1011/sys/src/9/power/boot.c:368,373
1991/0304    
{ 
	int n, f, tries; 
	char *srvname; 
	Dir dir; 
	char dirbuf[DIRLEN]; 
 
1991/0719    
	if(ask) 
1991/0304    
		outin("server", sys, sizeof(sys)); 
1991/0820/sys/src/9/power/boot.c:397,4181991/1011/sys/src/9/power/boot.c:397,404
1991/0304    
	if(!preamble(fd)) 
		return; 
1990/0227    
 
	print("post..."); 
1990/1127    
	sprint(buf, "#s/%s", srvname); 
1990/0227    
	f = create(buf, 1, 0666); 
	if(f < 0) 
		error("create"); 
	sprint(buf, "%d", fd); 
	if(write(f, buf, strlen(buf)) != strlen(buf)) 
		error("write"); 
	close(f); 
	f = create("#s/boot", 1, 0666); 
	if(f < 0) 
		error("create"); 
	sprint(buf, "%d", fd); 
	if(write(f, buf, strlen(buf)) != strlen(buf)) 
		error("write"); 
	close(f); 
1991/1011    
	srvcreate("boot", fd); 
	srvcreate("bootes", fd); 
1990/0427    
 
1990/0227    
	print("mount..."); 
	if(bind("/", "/", MREPL) < 0) 
1991/0820/sys/src/9/power/boot.c:420,4371991/1011/sys/src/9/power/boot.c:406,412
1990/11211    
	if(mount(fd, "/", MAFTER|MCREATE, "", "") < 0) 
1990/0227    
		error("mount"); 
1991/01151    
 
	/* 
	 * set the time from the access time of the root of the file server, 
	 * accessible as /.. 
	 */ 
	print("time..."); 
	if(stat("/..", dirbuf) < 0) 
		error("stat"); 
	convM2D(dirbuf, &dir); 
	f = open("#c/time", OWRITE); 
	sprint(dirbuf, "%ld", dir.atime); 
	write(f, dirbuf, strlen(dirbuf)); 
	close(f); 
1991/1011    
	settime(); 
1991/01151    
 
1990/0227    
	print("success\n"); 
1991/0108    
 
1991/0820/sys/src/9/power/boot.c:501,5041991/1011/sys/src/9/power/boot.c:476,531
1990/1202    
		strcpy(def, buf); 
	} 
1990/0427    
	return n; 
1991/1011    
} 
 
void 
srvcreate(char *name, int fd) 
{ 
	char *srvname; 
	int f; 
 
	srvname = strrchr(name, '/'); 
	if(srvname) 
		srvname++; 
	else 
		srvname = name; 
 
	sprint(buf, "#s/%s", srvname); 
	f = create(buf, 1, 0666); 
	if(f < 0) 
		error("create"); 
	sprint(buf, "%d", fd); 
	if(write(f, buf, strlen(buf)) != strlen(buf)) 
		error("write"); 
	close(f); 
} 
 
void 
settime(void) 
{ 
	char dirbuf[DIRLEN]; 
	Dir dir; 
	int f; 
 
	print("time..."); 
	/* 
	 *  set the time from the access time of the root 
	 *  of the file server 
	 */ 
	f = open("#s/boot", ORDWR); 
	if(f < 0) 
		return; 
	if(mount(f, "/n/boot", MREPL, "", "") < 0){ 
		close(f); 
		return; 
	} 
	close(f); 
	if(stat("/n/boot", dirbuf) < 0) 
		error("stat"); 
	convM2D(dirbuf, &dir); 
	sprint(dirbuf, "%ld", dir.atime); 
	unmount(0, "/n/boot"); 
	f = open("#c/time", OWRITE); 
	write(f, dirbuf, strlen(dirbuf)); 
	close(f); 
1990/0227    
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)