From 15abe49f09f426a8926134c57020ca1f630da31f Mon Sep 17 00:00:00 2001 From: Geoffrey Challen Date: Thu, 9 Feb 2017 09:53:00 -0500 Subject: [PATCH] Minor kernel changes. --- kern/vfs/vfslist.c | 20 ++++++++++++++++++++ kern/vfs/vfslookup.c | 7 +++++++ kern/vm/kmalloc.c | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/kern/vfs/vfslist.c b/kern/vfs/vfslist.c index 9cd2f4a..64f6a9d 100644 --- a/kern/vfs/vfslist.c +++ b/kern/vfs/vfslist.c @@ -129,6 +129,23 @@ vfs_biglock_acquire(void) if (!lock_do_i_hold(vfs_biglock)) { lock_acquire(vfs_biglock); } + else if (vfs_biglock_depth == 0) { + /* + * Supposedly we hold it, but the depth is 0. This may + * mean: (1) the count is messed up, or (2) + * lock_do_i_hold is lying. Since OS/161 ships out of + * the box with unimplemented locks (students + * implement them) that always return true, assume + * situation (2). In this case acquire the lock + * anyway. + * + * Once you have working locks, this won't be the + * case, and if you get here it should be situation + * (1), in which case the count is messed up and one + * can panic. + */ + lock_acquire(vfs_biglock); + } vfs_biglock_depth++; } @@ -381,6 +398,9 @@ vfs_doadd(const char *dname, int mountable, struct device *dev, struct fs *fs) unsigned index; int result; + /* Silence warning with gcc 4.8 -Og (but not -O2) */ + index = 0; + vfs_biglock_acquire(); name = kstrdup(dname); diff --git a/kern/vfs/vfslookup.c b/kern/vfs/vfslookup.c index 773cbcd..afeacea 100644 --- a/kern/vfs/vfslookup.c +++ b/kern/vfs/vfslookup.c @@ -135,6 +135,13 @@ getdevice(char *path, char **subpath, struct vnode **startvn) KASSERT(vfs_biglock_do_i_hold()); + /* + * Entirely empty filenames aren't legal. + */ + if (path[0] == 0) { + return EINVAL; + } + /* * Locate the first colon or slash. */ diff --git a/kern/vm/kmalloc.c b/kern/vm/kmalloc.c index 453b3cc..b8a1204 100644 --- a/kern/vm/kmalloc.c +++ b/kern/vm/kmalloc.c @@ -1065,6 +1065,10 @@ subpage_kfree(void *ptr) checksubpages(); + /* Silence warnings with gcc 4.8 -Og (but not -O2) */ + prpage = 0; + blktype = 0; + for (pr = allbase; pr; pr = pr->next_all) { prpage = PR_PAGEADDR(pr); blktype = PR_BLOCKTYPE(pr);