aboutsummaryrefslogtreecommitdiff
path: root/kernel/fs/s5fs/s5fs_subr.c
diff options
context:
space:
mode:
authorsotech117 <26747948+sotech117@users.noreply.github.com>2024-04-25 03:45:32 -0400
committerGitHub <noreply@github.com>2024-04-25 03:45:32 -0400
commitc9f4da6024393310e254a2cba679b1f1cc67607a (patch)
tree6f7a61225676b9578c0e0c46cdd54a10bad9c9e3 /kernel/fs/s5fs/s5fs_subr.c
parenta17999858ddaada83071d953d920e3c2a2b390c8 (diff)
parentfb4b8fbec69f50c7386017896f0add4d46314a1d (diff)
Merge branch 'brown-cs1690:master' into master
Diffstat (limited to 'kernel/fs/s5fs/s5fs_subr.c')
-rw-r--r--kernel/fs/s5fs/s5fs_subr.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/kernel/fs/s5fs/s5fs_subr.c b/kernel/fs/s5fs/s5fs_subr.c
index 0187e74..27b6a92 100644
--- a/kernel/fs/s5fs/s5fs_subr.c
+++ b/kernel/fs/s5fs/s5fs_subr.c
@@ -91,7 +91,6 @@ static inline void s5_release_file_block(pframe_t **pfp)
pframe_release(pfp);
}
-#ifdef OLD
/* Given a file and a file block number, return the disk block number of the
* desired file block.
*
@@ -100,6 +99,8 @@ static inline void s5_release_file_block(pframe_t **pfp)
* the file
* alloc - If set, allocate the block / indirect block as necessary
* If clear, don't allocate sparse blocks
+ * newp - Return parameter that should be set to 1 if the returned
+ * block number is new (block has just been allocated)
*
* Return a disk block number on success, or:
* - 0: The block is sparse, and alloc is clear, OR
@@ -121,20 +122,13 @@ static inline void s5_release_file_block(pframe_t **pfp)
* 1) file_blocknum < S_NDIRECT_BLOCKS
* 2) Indirect block is not allocated but alloc is set. Be careful not to
* leak a block in an error case!
+ 2a) Make sure you allocate the indirect block on disk and create a
+ corresponding pframe_t on the mobj (Hint: see s5_cache_and_clear_block).
* 3) Indirect block is allocated. The desired block may be sparse, and you
* may have to allocate it.
* 4) The indirect block has not been allocated and alloc is clear.
*/
long s5_file_block_to_disk_block(s5_node_t *sn, size_t file_blocknum,
- int alloc)
-{
- NOT_YET_IMPLEMENTED("S5FS: s5_file_block_to_disk_block");
- return -1;
-}
-#endif
-
-
-long s5_file_block_to_disk_block(s5_node_t *sn, size_t file_blocknum,
int alloc, int *newp)
{
NOT_YET_IMPLEMENTED("S5FS: s5_file_block_to_disk_block");
@@ -211,7 +205,6 @@ ssize_t s5_write_file(s5_node_t *sn, size_t pos, const char *buf, size_t len)
return -1;
}
-#ifdef OLD
/* Allocate one block from the filesystem.
*
* Return the block number of the newly allocated block, or:
@@ -243,13 +236,6 @@ static long s5_alloc_block(s5fs_t *s5fs)
NOT_YET_IMPLEMENTED("S5FS: s5_alloc_block");
return -1;
}
-#endif
-
-static long s5_alloc_block(s5fs_t *s5fs)
-{
- NOT_YET_IMPLEMENTED("S5FS: s5_alloc_block");
- return -1;
-}
/*
* The exact opposite of s5_alloc_block: add blockno to the free list of the
@@ -282,6 +268,9 @@ static void s5_free_block(s5fs_t *s5fs, blocknum_t blockno)
else
{
s->s5s_free_blocks[s->s5s_nfree++] = blockno;
+ // only delete in this case b/c in first case we're still using that
+ // block as a "meta" block, just to store free block numbers
+ mobj_delete_pframe(&s5fs->s5f_mobj, blockno);
}
s5_unlock_super(s5fs);
}