projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix line wrapping.
[pintos-anon]
/
src
/
filesys
/
inode.c
diff --git
a/src/filesys/inode.c
b/src/filesys/inode.c
index bd68167baa1c5c4b2bcfd02c73b99c194e102c87..17f4b4680f656fdbda2e8344b36366ba478a6315 100644
(file)
--- a/
src/filesys/inode.c
+++ b/
src/filesys/inode.c
@@
-76,6
+76,9
@@
inode_create (disk_sector_t sector, off_t length)
bool success = false;
ASSERT (length >= 0);
bool success = false;
ASSERT (length >= 0);
+
+ /* If this assertion fails, the inode structure is not exactly
+ one sector in size, and you should fix that. */
ASSERT (sizeof *disk_inode == DISK_SECTOR_SIZE);
disk_inode = calloc (1, sizeof *disk_inode);
ASSERT (sizeof *disk_inode == DISK_SECTOR_SIZE);
disk_inode = calloc (1, sizeof *disk_inode);
@@
-162,11
+165,14
@@
inode_close (struct inode *inode)
{
/* Remove from inode list and release lock. */
list_remove (&inode->elem);
{
/* Remove from inode list and release lock. */
list_remove (&inode->elem);
-
+
/* Deallocate blocks if removed. */
/* Deallocate blocks if removed. */
- if (inode->removed)
- free_map_release (inode->sector,
- bytes_to_sectors (inode->data.length));
+ if (inode->removed)
+ {
+ free_map_release (inode->sector, 1);
+ free_map_release (inode->data.start,
+ bytes_to_sectors (inode->data.length));
+ }
free (inode);
}
free (inode);
}
@@
-255,7
+261,7
@@
inode_write_at (struct inode *inode, const void *buffer_, off_t size,
while (size > 0)
{
/* Sector to write, starting byte offset within sector. */
while (size > 0)
{
/* Sector to write, starting byte offset within sector. */
-
off
_t sector_idx = byte_to_sector (inode, offset);
+
disk_sector
_t sector_idx = byte_to_sector (inode, offset);
int sector_ofs = offset % DISK_SECTOR_SIZE;
/* Bytes left in inode, bytes left in sector, lesser of the two. */
int sector_ofs = offset % DISK_SECTOR_SIZE;
/* Bytes left in inode, bytes left in sector, lesser of the two. */