| plan 9 kernel history: overview | file list | diff list |
1993/0330/boot/settime.c (diff list | history)
| 1992/0318/sys/src/9/boot/settime.c:34,40 – 1992/0325/sys/src/9/boot/settime.c:34,40 (short | long) | ||
| 1992/0318 | f = open("#s/boot", ORDWR); if(f < 0) return; | |
| 1992/0325 | if(mount(f, "/n/boot", MREPL, "", sauth) < 0){ | |
| 1992/0318 | close(f); return; } | |
| 1992/0325/sys/src/9/boot/settime.c:3,8 – 1992/0611/sys/src/9/boot/settime.c:3,10 (short | long) | ||
| 1992/0318 | #include <fcall.h> #include "../boot/boot.h" | |
| 1992/0611 | static long lusertime(char*); | |
| 1992/0318 | void settime(int islocal) { | |
| 1992/0325/sys/src/9/boot/settime.c:25,31 – 1992/0611/sys/src/9/boot/settime.c:27,36 | ||
| 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); | |
| 1992/0318 | } if(timeset == 0){ /* | |
| 1992/0325/sys/src/9/boot/settime.c:52,61 – 1992/0611/sys/src/9/boot/settime.c:57,152 | ||
| 1992/0318 | write(f, dirbuf, strlen(dirbuf)); close(f); } | |
| 1992/0611 | if(write(f, dirbuf, strlen(dirbuf)) < 0) warning("can't set #c/time"); | |
| 1992/0318 | close(f); | |
| 1992/0611 | } #define SEC2MIN 60L #define SEC2HOUR (60L*SEC2MIN) #define SEC2DAY (24L*SEC2HOUR) int g2(char **pp) { int v; v = 10*((*pp)[0]-'0') + (*pp)[1]-'0'; *pp += 2; return v; } /* * days per month plus days/year */ static int dmsize[] = { 365, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static int ldmsize[] = { 366, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; /* * return the days/month for the given year */ static int * yrsize(int yr) { if((yr % 4) == 0) return ldmsize; else return dmsize; } /* * compute seconds since Jan 1 1970 */ static long lusertime(char *argbuf) { char *buf; ulong secs; int i, y, m; int *d2m; buf = argbuf; i = strlen(buf); if(i != 10 && i != 12) return -1; secs = 0; y = g2(&buf); m = g2(&buf); if(y < 70) y += 2000; else y += 1900; /* * seconds per year */ for(i = 1970; i < y; i++){ d2m = yrsize(i); secs += d2m[0] * SEC2DAY; } /* * seconds per month */ d2m = yrsize(y); for(i = 1; i < m; i++) secs += d2m[i] * SEC2DAY; secs += (g2(&buf)-1) * SEC2DAY; secs += g2(&buf) * SEC2HOUR; secs += g2(&buf) * SEC2MIN; if(*buf) secs += g2(&buf); sprint(argbuf, "%ld", secs); return secs; | |
| 1992/0318 | } | |
| 1992/0611/sys/src/9/boot/settime.c:12,18 – 1992/0808/sys/src/9/boot/settime.c:12,17 (short | long) | ||
| 1992/0318 | int timeset; Dir dir; char dirbuf[DIRLEN]; | |
| 1992/0808/sys/src/9/boot/settime.c:5,10 – 1992/0909/sys/src/9/boot/settime.c:5,12 (short | long) | ||
| 1992/0318 | ||
| 1992/0611 | static long lusertime(char*); | |
| 1992/0909 | char *timeserver = "#s/boot"; | |
| 1992/0318 | void settime(int islocal) { | |
| 1992/0808/sys/src/9/boot/settime.c:35,41 – 1992/0909/sys/src/9/boot/settime.c:37,43 | ||
| 1992/0318 | /* * set the time from the access time of the root */ | |
| 1992/0909 | f = open(timeserver, ORDWR); | |
| 1992/0318 | if(f < 0) return; | |
| 1992/0325 | if(mount(f, "/n/boot", MREPL, "", sauth) < 0){ | |
| 1992/0909/sys/src/9/boot/settime.c:40,49 – 1992/0912/sys/src/9/boot/settime.c:40,50 (short | long) | ||
| 1992/0909 | f = open(timeserver, ORDWR); | |
| 1992/0318 | if(f < 0) return; | |
| 1992/0325 |
| |
| 1992/0318 |
| |
| 1992/0912 | if(mount(f, "/n/boot", MREPL, "", sauth) < 0) if(mount(f, "/n/boot", MREPL, "", "any") < 0){ close(f); return; } | |
| 1992/0318 | close(f); if(stat("/n/boot", dirbuf) < 0) fatal("stat"); | |
| 1992/0912/sys/src/9/boot/settime.c:1,5 – 1993/0330/sys/src/9/boot/settime.c:1,6 (short | long) | ||
| 1992/0318 | #include <u.h> #include <libc.h> | |
| 1993/0330 | #include <auth.h> | |
| 1992/0318 | #include <fcall.h> #include "../boot/boot.h" | |
| 1992/0912/sys/src/9/boot/settime.c:40,50 – 1993/0330/sys/src/9/boot/settime.c:41,51 | ||
| 1992/0909 | f = open(timeserver, ORDWR); | |
| 1992/0318 | if(f < 0) return; | |
| 1992/0912 |
| |
| 1993/0330 | if(mount(f, "/n/boot", MREPL, "") < 0){ warning("settime mount"); close(f); return; } | |
| 1992/0318 | close(f); if(stat("/n/boot", dirbuf) < 0) fatal("stat"); | |
| 1993/0330/sys/src/9/boot/settime.c:42,48 – 1993/0501/sys/src/9/boot/settime.c:42,48 (short | long) | ||
| 1992/0318 | if(f < 0) return; | |
| 1993/0330 | if(mount(f, "/n/boot", MREPL, "") < 0){ | |
| 1993/0501 | warning("settime mount"); | |
| 1993/0330 | close(f); return; } | |
| 1993/0330/sys/src/9/boot/settime.c:66,71 – 1993/0501/sys/src/9/boot/settime.c:66,72 | ||
| 1992/0611 | if(write(f, dirbuf, strlen(dirbuf)) < 0) warning("can't set #c/time"); | |
| 1992/0318 | close(f); | |
| 1993/0501 | print("\n"); | |
| 1992/0611 | } #define SEC2MIN 60L | |
| 1993/0501/sys/src/9/boot/settime.c:99,107 – 1999/0113/sys/src/9/boot/settime.c:99,108 (short | long) | ||
| 1992/0611 | * return the days/month for the given year */ static int * | |
| 1999/0113 | yrsize(int y) | |
| 1992/0611 | { | |
| 1999/0113 | if((y%4) == 0 && ((y%100) != 0 || (y%400) == 0)) | |
| 1992/0611 | return ldmsize; else return dmsize; | |
| 1999/0113/sys/src/9/boot/settime.c:52,65 – 1999/0305/sys/src/9/boot/settime.c:52,57 (short | long) | ||
| 1992/0318 | convM2D(dirbuf, &dir); sprint(dirbuf, "%ld", dir.atime); unmount(0, "/n/boot"); | |
| 1999/0305/sys/src/9/boot/settime.c:41,57 – 2000/0310/sys/src/9/boot/settime.c:41,57 (short | long) | ||
| 1992/0909 | f = open(timeserver, ORDWR); | |
| 1992/0318 | if(f < 0) return; | |
| 1993/0330 |
| |
| 2000/0310 | if(mount(f, "/mnt", MREPL, "") < 0){ | |
| 1993/0501 | warning("settime mount"); | |
| 1993/0330 | close(f); return; } | |
| 1992/0318 | close(f); | |
| 2000/0310 | if(stat("/mnt", dirbuf) < 0) | |
| 1992/0318 | fatal("stat"); convM2D(dirbuf, &dir); sprint(dirbuf, "%ld", dir.atime); | |
| 2000/0310 | unmount(0, "/mnt"); | |
| 1992/0318 | } f = open("#c/time", OWRITE); | |
| 2000/0310/sys/src/9/boot/settime.c:3,8 – 2001/0527/sys/src/9/boot/settime.c:3,11 (short | long) | ||
| 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,20 – 2001/0527/sys/src/9/boot/settime.c:16,23 | ||
| 1992/0318 | { int n, f; int timeset; | |
| 2001/0527 | Dir dir[2]; char timebuf[64]; | |
| 1992/0318 | print("time..."); timeset = 0; | |
| 2000/0310/sys/src/9/boot/settime.c:24,38 – 2001/0527/sys/src/9/boot/settime.c:27,41 | ||
| 1992/0318 | */ f = open("#r/rtc", ORDWR); if(f >= 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{ | |
| 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,61 – 2001/0527/sys/src/9/boot/settime.c:50,64 | ||
| 1993/0330 | return; } | |
| 1992/0318 | close(f); | |
| 2000/0310 |
| |
| 2001/0527 | if(stat("/mnt", statbuf, sizeof statbuf) < 0) | |
| 1992/0318 | fatal("stat"); | |
| 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 |
| |
| 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"); | |
| 2001/0527/sys/src/9/boot/settime.c:12,18 – 2001/0819/sys/src/9/boot/settime.c:12,18 (short | long) | ||
| 1992/0909 | char *timeserver = "#s/boot"; | |
| 1992/0318 | void | |
| 2001/0819 | settime(int islocal, int afd) | |
| 1992/0318 | { int n, f; int timeset; | |
| 2001/0527/sys/src/9/boot/settime.c:44,60 – 2001/0819/sys/src/9/boot/settime.c:44,60 | ||
| 1992/0909 | f = open(timeserver, ORDWR); | |
| 1992/0318 | if(f < 0) return; | |
| 2000/0310 |
| |
| 2001/0819 | if(mount(f, afd, "/tmp", MREPL, "") < 0){ | |
| 1993/0501 | warning("settime mount"); | |
| 1993/0330 | close(f); return; } | |
| 1992/0318 | close(f); | |
| 2001/0527 |
| |
| 2001/0819 | if(stat("/tmp", statbuf, sizeof statbuf) < 0) | |
| 1992/0318 | fatal("stat"); | |
| 2001/0527 | convM2D(statbuf, sizeof statbuf, &dir[0], (char*)&dir[1]); sprint(timebuf, "%ld", dir[0].atime); | |
| 2000/0310 |
| |
| 2001/0819 | unmount(0, "/tmp"); | |
| 1992/0318 | } f = open("#c/time", OWRITE); | |
| 2001/0819/sys/src/9/boot/settime.c:3,11 – 2002/0115/sys/src/9/boot/settime.c:3,8 (short | long) | ||
|
Remove 9P2000 transition code.
rsc Fri Mar 4 12:44:25 2005 | ||
| 1993/0330 | #include <auth.h> | |
| 1992/0318 | #include <fcall.h> #include "../boot/boot.h" | |
| 2001/0527 |
| |
| 1992/0318 | ||
| 1992/0611 | static long lusertime(char*); | |
| 2002/0115/sys/src/9/boot/settime.c:9,15 – 2002/1002/sys/src/9/boot/settime.c:9,15 (short | long) | ||
| 1992/0909 | char *timeserver = "#s/boot"; | |
| 1992/0318 | void | |
| 2001/0819 |
| |
| 2002/1002 | settime(int islocal, int afd, char *rp) | |
| 1992/0318 | { int n, f; int timeset; | |
| 2002/0115/sys/src/9/boot/settime.c:41,47 – 2002/1002/sys/src/9/boot/settime.c:41,47 | ||
| 1992/0909 | f = open(timeserver, ORDWR); | |
| 1992/0318 | if(f < 0) return; | |
| 2001/0819 |
| |
| 2002/1002 | if(mount(f, afd, "/tmp", MREPL, rp) < 0){ | |
| 1993/0501 | warning("settime mount"); | |
| 1993/0330 | close(f); return; | |