Minor kernel changes.

This commit is contained in:
Geoffrey Challen 2017-02-09 09:53:00 -05:00
parent 0f0c5fcfc7
commit 15abe49f09
3 changed files with 31 additions and 0 deletions

View File

@ -129,6 +129,23 @@ vfs_biglock_acquire(void)
if (!lock_do_i_hold(vfs_biglock)) { if (!lock_do_i_hold(vfs_biglock)) {
lock_acquire(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++; vfs_biglock_depth++;
} }
@ -381,6 +398,9 @@ vfs_doadd(const char *dname, int mountable, struct device *dev, struct fs *fs)
unsigned index; unsigned index;
int result; int result;
/* Silence warning with gcc 4.8 -Og (but not -O2) */
index = 0;
vfs_biglock_acquire(); vfs_biglock_acquire();
name = kstrdup(dname); name = kstrdup(dname);

View File

@ -135,6 +135,13 @@ getdevice(char *path, char **subpath, struct vnode **startvn)
KASSERT(vfs_biglock_do_i_hold()); KASSERT(vfs_biglock_do_i_hold());
/*
* Entirely empty filenames aren't legal.
*/
if (path[0] == 0) {
return EINVAL;
}
/* /*
* Locate the first colon or slash. * Locate the first colon or slash.
*/ */

View File

@ -1065,6 +1065,10 @@ subpage_kfree(void *ptr)
checksubpages(); checksubpages();
/* Silence warnings with gcc 4.8 -Og (but not -O2) */
prpage = 0;
blktype = 0;
for (pr = allbase; pr; pr = pr->next_all) { for (pr = allbase; pr; pr = pr->next_all) {
prpage = PR_PAGEADDR(pr); prpage = PR_PAGEADDR(pr);
blktype = PR_BLOCKTYPE(pr); blktype = PR_BLOCKTYPE(pr);