projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use runtime options instead of conditional compilation for MLFQS,
[pintos-anon]
/
src
/
filesys
/
file.c
diff --git
a/src/filesys/file.c
b/src/filesys/file.c
index cd5fe3ee05ace31b9981805862fb72260a89f0d8..e8818c0029383a7d3a0f139963874bf81021dbc2 100644
(file)
--- a/
src/filesys/file.c
+++ b/
src/filesys/file.c
@@
-45,6
+45,7
@@
file_close (struct file *file)
inode_close (file->inode);
free (file->bounce);
inode_close (file->inode);
free (file->bounce);
+ free (file);
}
/* Reads SIZE bytes from FILE into BUFFER,
}
/* Reads SIZE bytes from FILE into BUFFER,
@@
-75,7
+76,7
@@
file_read_at (struct file *file, void *buffer_, off_t size,
while (size > 0)
{
/* Disk sector to read, starting byte offset within sector. */
while (size > 0)
{
/* Disk sector to read, starting byte offset within sector. */
-
off_t sector_idx = inode_byte_to_sector (file->inode, file_ofs)
;
+
disk_sector_t sector_idx
;
int sector_ofs = file_ofs % DISK_SECTOR_SIZE;
/* Bytes left in file, bytes left in sector, lesser of the two. */
int sector_ofs = file_ofs % DISK_SECTOR_SIZE;
/* Bytes left in file, bytes left in sector, lesser of the two. */
@@
-90,6
+91,7
@@
file_read_at (struct file *file, void *buffer_, off_t size,
/* Read sector into bounce buffer, then copy into caller's
buffer. */
/* Read sector into bounce buffer, then copy into caller's
buffer. */
+ sector_idx = inode_byte_to_sector (file->inode, file_ofs);
disk_read (filesys_disk, sector_idx, file->bounce);
memcpy (buffer + bytes_read, file->bounce + sector_ofs, chunk_size);
disk_read (filesys_disk, sector_idx, file->bounce);
memcpy (buffer + bytes_read, file->bounce + sector_ofs, chunk_size);
@@
-133,8
+135,8
@@
file_write_at (struct file *file, const void *buffer_, off_t size,
while (size > 0)
{
while (size > 0)
{
- /* S
tarting byte offset within sector to read
. */
- off_t sector_idx
= inode_byte_to_sector (file->inode, file_ofs)
;
+ /* S
ector to write, starting byte offset within sector
. */
+ off_t sector_idx;
int sector_ofs = file_ofs % DISK_SECTOR_SIZE;
/* Bytes left in file, bytes left in sector, lesser of the two. */
int sector_ofs = file_ofs % DISK_SECTOR_SIZE;
/* Bytes left in file, bytes left in sector, lesser of the two. */
@@
-150,6
+152,7
@@
file_write_at (struct file *file, const void *buffer_, off_t size,
/* If the sector contains data before or after the chunk
we're writing, then we need to read in the sector
first. Otherwise we start with a sector of all zeros. */
/* If the sector contains data before or after the chunk
we're writing, then we need to read in the sector
first. Otherwise we start with a sector of all zeros. */
+ sector_idx = inode_byte_to_sector (file->inode, file_ofs);
if (sector_ofs > 0 || chunk_size < sector_left)
disk_read (filesys_disk, sector_idx, file->bounce);
else
if (sector_ofs > 0 || chunk_size < sector_left)
disk_read (filesys_disk, sector_idx, file->bounce);
else