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

2000/0310/boot/settime.c (diff list | history)

2000/0310/sys/src/9/boot/settime.c:3,82001/0527/sys/src/9/boot/settime.c:3,11 (short | long | prev | next)
1993/0330    
#include <auth.h> 
1992/0318    
#include <fcall.h> 
#include "../boot/boot.h" 
2001/0527    
/*BUG transition*/ 
int client9p=2; 
int kernel9p=2; 
1992/0318    
 
1992/0611    
static long lusertime(char*); 
 
2000/0310/sys/src/9/boot/settime.c:13,202001/0527/sys/src/9/boot/settime.c:16,23
1992/0318    
{ 
	int n, f; 
	int timeset; 
	Dir dir; 
	char dirbuf[DIRLEN]; 
2001/0527    
	Dir dir[2]; 
	char timebuf[64]; 
1992/0318    
 
	print("time..."); 
	timeset = 0; 
2000/0310/sys/src/9/boot/settime.c:24,382001/0527/sys/src/9/boot/settime.c:27,41
1992/0318    
		 */ 
		f = open("#r/rtc", ORDWR); 
		if(f >= 0){ 
			if((n = read(f, dirbuf, sizeof(dirbuf)-1)) > 0){ 
				dirbuf[n] = 0; 
2001/0527    
			if((n = read(f, timebuf, sizeof(timebuf)-1)) > 0){ 
				timebuf[n] = '\0'; 
1992/0318    
				timeset = 1; 
			} 
			close(f); 
1992/0611    
		}else do{ 
			strcpy(dirbuf, "yymmddhhmm[ss]"); 
			outin("\ndate/time ", dirbuf, sizeof(dirbuf)); 
		}while((timeset=lusertime(dirbuf)) <= 0); 
2001/0527    
			strcpy(timebuf, "yymmddhhmm[ss]"); 
			outin("\ndate/time ", timebuf, sizeof(timebuf)); 
		}while((timeset=lusertime(timebuf)) <= 0); 
1992/0318    
	} 
	if(timeset == 0){ 
		/* 
2000/0310/sys/src/9/boot/settime.c:47,612001/0527/sys/src/9/boot/settime.c:50,64
1993/0330    
			return; 
		} 
1992/0318    
		close(f); 
2000/0310    
		if(stat("/mnt", dirbuf) < 0) 
2001/0527    
		if(stat("/mnt", statbuf, sizeof statbuf) < 0) 
1992/0318    
			fatal("stat"); 
		convM2D(dirbuf, &dir); 
		sprint(dirbuf, "%ld", dir.atime); 
2001/0527    
		convM2D(statbuf, sizeof statbuf, &dir[0], (char*)&dir[1]); 
		sprint(timebuf, "%ld", dir[0].atime); 
2000/0310    
		unmount(0, "/mnt"); 
1992/0318    
	} 
 
	f = open("#c/time", OWRITE); 
1992/0611    
	if(write(f, dirbuf, strlen(dirbuf)) < 0) 
2001/0527    
	if(write(f, timebuf, strlen(timebuf)) < 0) 
1992/0611    
		warning("can't set #c/time"); 
1992/0318    
	close(f); 
1993/0501    
	print("\n"); 


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