diff options
-rwxr-xr-x | hyra-build.sh | 1 | ||||
-rw-r--r-- | sys/fs/ctlfs.c | 20 | ||||
-rw-r--r-- | usr.bin/date/date.c | 39 |
3 files changed, 37 insertions, 23 deletions
diff --git a/hyra-build.sh b/hyra-build.sh index d8903c8..caa6e45 100755 --- a/hyra-build.sh +++ b/hyra-build.sh @@ -153,7 +153,6 @@ result() { then hard_clean # XXX: For safety echo "Installer is at ./Hyra-install.iso" - echo "!!WARNING!!: Installer is _automatic_" echo "!!NOTE!!: OSMORA is not responsible for incidental data loss" else echo "Boot image is at ./Hyra.iso" diff --git a/sys/fs/ctlfs.c b/sys/fs/ctlfs.c index efbf448..64d3a1a 100644 --- a/sys/fs/ctlfs.c +++ b/sys/fs/ctlfs.c @@ -371,25 +371,7 @@ ctlfs_read(struct vnode *vp, struct sio_txn *sio) static int ctlfs_reclaim(struct vnode *vp) { - struct ctlfs_hdr *hp; - - if (vp->data == NULL) { - return 0; - } - - /* Ensure the magic is correct */ - hp = vp->data; - switch (hp->magic) { - case CTLFS_NODE_MAG: - case CTLFS_ENTRY_MAG: - dynfree(hp->name); - break; - default: - pr_error("reclaim: bad magic in vp\n"); - break; - } - - dynfree(vp->data); + vp->data = NULL; return 0; } diff --git a/usr.bin/date/date.c b/usr.bin/date/date.c index 2f3b11f..a47e3eb 100644 --- a/usr.bin/date/date.c +++ b/usr.bin/date/date.c @@ -28,14 +28,34 @@ */ #include <sys/time.h> +#include <sys/cdefs.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> +#define MONTHS_PER_YEAR 12 +#define DAYS_PER_WEEK 7 + +/* Months of the year */ +static const char *montab[] = { + "Jan", "Feb", "Mar", + "Apr", "May", "Jun", + "Jul", "Aug", "Sep", + "Oct", "Nov", "Dec" +}; + +/* Days of the week */ +static const char *daytab[] = { + "Sat", "Sun", "Mon", + "Tue", "Wed", "Thu", + "Fri" +}; + int main(void) { - char date_str[16]; + const char *day, *month; + char date_str[32]; struct date d; int rtc_fd; @@ -46,8 +66,21 @@ main(void) read(rtc_fd, &d, sizeof(d)); close(rtc_fd); - snprintf(date_str, sizeof(date_str), "%02d:%02d:%02d\n", - d.hour, d.min, d.sec); + /* This should not happen */ + if (__unlikely(d.month > MONTHS_PER_YEAR)) { + printf("got bad month %d from RTC\n", d.month); + return -1; + } + if (__unlikely(d.month == 0 || d.day == 0)) { + printf("got zero month/day from RTC\n"); + return -1; + } + + day = daytab[d.day % DAYS_PER_WEEK]; + month = montab[d.month - 1]; + + snprintf(date_str, sizeof(date_str), "%s %s %d %02d:%02d:%02d\n", + day, month, d.day, d.hour, d.min, d.sec); fputs(date_str, stdout); return 0; } |