From 2293493bfd5dbeeb02e851151168695298814117 Mon Sep 17 00:00:00 2001 From: Sergey Date: Sun, 20 Jul 2014 17:23:57 -0700 Subject: [PATCH] Fixed bugs in fsutil. --- sys/pic32/exception.c | 10 +++++----- tools/fsutil/fsutil.c | 3 +++ tools/fsutil/inode.c | 1 - tools/fsutil/mount.c | 13 +++++++++---- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/sys/pic32/exception.c b/sys/pic32/exception.c index 2d70c7d..5434a85 100644 --- a/sys/pic32/exception.c +++ b/sys/pic32/exception.c @@ -158,7 +158,7 @@ dumpregs (frame) printf( "*******STACK DUMP START*************\n"); printf( "frame = %8x\n", frame ); printf( "stack data\n" ); - while( p <= stacktop ) + while( p <= stacktop ) { printf( " %8x", *p++ ); if( p <= stacktop ) printf( " %8x", *p++ ); @@ -343,14 +343,14 @@ exception (frame) mips_write_c0_register (C0_COMPARE, 0, c); } while ((int) (c - (unsigned)mips_read_c0_register (C0_COUNT, 0)) < 0); hardclock ((caddr_t) frame [FRAME_PC], status); - + #ifdef POWER_ENABLED power_switch_check(); #endif #ifdef UARTUSB_ENABLED /* Poll USB on every timer tick. */ - usbintr(0); + usbintr(0); #endif break; #ifdef UART1_ENABLED @@ -389,7 +389,7 @@ exception (frame) #ifdef UARTUSB_ENABLED case PIC32_VECT_USB: /* USB */ IFSCLR(1) = 1 << (PIC32_IRQ_USB - 32); - usbintr(0); + usbintr(0); break; #endif @@ -418,7 +418,7 @@ exception (frame) if (sp < u.u_procp->p_daddr + u.u_dsize) { /* Process has trashed its stack; give it an illegal * instruction violation to halt it in its tracks. */ - panic ("unexpected exception 2"); + panic ("unexpected exception 2"); psig = SIGSEGV; break; } diff --git a/tools/fsutil/fsutil.c b/tools/fsutil/fsutil.c index c1b6887..20327b6 100644 --- a/tools/fsutil/fsutil.c +++ b/tools/fsutil/fsutil.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -354,6 +355,7 @@ void add_device (fs_t *fs, char *name, char *spec) return; } dev.addr[1] = majr << 8 | minr; + time (&dev.mtime); fs_inode_save (&dev, 1); } @@ -408,6 +410,7 @@ void add_file (fs_t *fs, char *name) } } file.inode.mtime = st.st_mtime; + file.inode.dirty = 1; fs_file_close (&file); fclose (fd); } diff --git a/tools/fsutil/inode.c b/tools/fsutil/inode.c index 418f953..d021cce 100644 --- a/tools/fsutil/inode.c +++ b/tools/fsutil/inode.c @@ -161,7 +161,6 @@ int fs_inode_save (fs_inode_t *inode, int force) BSDFS_BSIZE / BSDFS_INODES_PER_BLOCK; time (&inode->atime); - //time (&inode->mtime); if (! fs_seek (inode->fs, offset)) return 0; diff --git a/tools/fsutil/mount.c b/tools/fsutil/mount.c index f96bab6..bb8f0be 100644 --- a/tools/fsutil/mount.c +++ b/tools/fsutil/mount.c @@ -56,6 +56,11 @@ static void printlog(const char *format, ...) } } +static dev_t make_rdev(unsigned raw) +{ + return makedev (raw >> 8, raw & 0xff); +} + /* * Copy data to struct stat. */ @@ -66,7 +71,7 @@ static int getstat (fs_inode_t *inode, struct stat *statbuf) statbuf->st_nlink = inode->nlink; /* number of hard links */ statbuf->st_uid = inode->uid; /* user ID of owner */ statbuf->st_gid = inode->gid; /* group ID of owner */ - statbuf->st_rdev = 0; /* device ID (if special file) */ + statbuf->st_rdev = 0; /* device ID (if special file) */ statbuf->st_size = inode->size; /* total size, in bytes */ statbuf->st_blocks = inode->size >> 9; /* number of blocks allocated */ statbuf->st_atime = inode->atime; /* time of last access */ @@ -82,11 +87,11 @@ static int getstat (fs_inode_t *inode, struct stat *statbuf) break; case INODE_MODE_FCHR: /* character special */ statbuf->st_mode |= S_IFCHR; - statbuf->st_rdev = inode->addr[1]; + statbuf->st_rdev = make_rdev (inode->addr[1]); break; case INODE_MODE_FBLK: /* block special */ statbuf->st_mode |= S_IFBLK; - statbuf->st_rdev = inode->addr[1]; + statbuf->st_rdev = make_rdev (inode->addr[1]); break; case INODE_MODE_FLNK: /* symbolic link */ statbuf->st_mode |= S_IFLNK; @@ -527,7 +532,7 @@ int op_mknod(const char *path, mode_t mode, dev_t dev) return -EIO; } if (S_ISCHR(mode) || S_ISBLK(mode)) { - inode.addr[1] = dev; + inode.addr[1] = major(dev) << 8 | minor(dev); } inode.mtime = time(0); inode.dirty = 1;