X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffilesys%2Finode.c;h=d890ed8d3c7f0375dc9f3a6a1178254d2c2db011;hb=bfe761705d4c6e1bb9e600ab774398b225a55f3f;hp=8e954abc32f35c782cd04c9f0715a7291a86edbb;hpb=586d828663e6d77914946c5823bc91ed739682d0;p=pintos-anon diff --git a/src/filesys/inode.c b/src/filesys/inode.c index 8e954ab..d890ed8 100644 --- 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); + + /* 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); @@ -140,13 +143,20 @@ inode_open (disk_sector_t sector) /* Reopens and returns INODE. */ struct inode * -inode_reopen (struct inode *inode) +inode_reopen (struct inode *inode) { - if (inode != NULL) + if (inode != NULL) inode->open_cnt++; return inode; } +/* Returns INODE's inode number. */ +disk_sector_t +inode_get_inumber (const struct inode *inode) +{ + return inode->sector; +} + /* Closes INODE and writes it to disk. If this was the last reference to INODE, frees its memory. If INODE was also a removed inode, frees its blocks. */