This page lists all official clarifications and some hints for lab 3:

josfs_write and josfs_read return values

The header on josfs_write says "Outputs: 0 on success, -(error code) on error"

but the code given to you says:

return (retval >= 0 ? amount : retval);

This means josfs_write actually returns the number of bytes written, which is usually greater than 0. So, if you calculated "amount" correctly, then just set "retval" >= 0 and use the given code to return from josf_write. Note this is how the write system call behaves (see "$man 2 write" for details).

The same goes for josfs_read.

Mounting JOSFS on network drives

Some people seem to be having trouble mounting JOSFS anywhere on a network drive (e.g. your SEASnet home directory). An updated josfsformat.c was sent out to the mailing list and posted on CourseWeb that fixes this problem.

bitvector_clear() bug fix

The handed out bitvector_clear code contains a major bug. Please change the following line:

((uint32_t *) vector) [i / 32] &= (1 << (i % 32));

to:

((uint32_t *) vector) [i / 32] &= ~(1 << (i % 32));

Note the tilde.

ERRSPC = ENOSPC

The comment for change_size says to return -ERRSPC when there are no free disk block available. This should say to return -ENOSPC.

copy_to_user()

unsigned long copy_to_user(void __user* to, const void * from, unsigned long n)

to - destination address in user space
from - source address in kernel space
n - number of bytes to copy

return value - the number of bytes that did NOT get copied. On success, copy_to_user() should return 0.

The free block bitmap

There is no special structure for accessing the free block bitmap. You can access the bitmap by getting a pointer to the data in the disk block and using the provided bitvector_ operations.

You need to consider the possibility that your file system requires more than 1 block of free block bitmap. The approach is fairly simple: whenever you're performing a free block bitmap operation (e.g allocate_block, free_block), see which block of free block bitmap your current index would be located in. The status for block number's [0, JOSFS_BLKBITSIZE) are stored in the first block of the free block bitmap (logical block #2), [JOSFS_BLKBITSIZE, 2*JOSFS_BLKBITSIZE) in the second block of the free block bitmap (logical block #3), etc. You can determine how large the free block bitmap needs to be by looking at the size of the disk (see struct josfs_super).

jinode_blockno() and jinode_data()

jinode_blockno takes a josfs_inode pointer and a desired byte offset into the file that the inode represents, and returns the disk block number that contains that byte. Look at the implementation to see more about what it's doing. Assuming you have a josfs_inode pointer called 'inode', jinode_blockno(inode, 5000) will tell you what block number byte 5000 of the file is in.

jinode_data does essentially the same thing, except it returns a pointer to the requested byte rather than the disk block number that the byte resides in. Again, look at the implementation. It just calls jinode_blockno to get the block number and then uses jblock to get the pointer. Calling jinode_data(inode, 5000) will give you a pointer to the 5000th byte of the file.

updated 5/28/05