Top Banner
Xv6 File System Zhewen Song 11/28/2017
8

Xv6 File System - pages.cs.wisc.edupages.cs.wisc.edu › ~gerald › cs537 › Fall17 › handouts › p5.pdfNov 28, 2017  · Bitmap in xv6 •Each bit in the bitmap is associated

Feb 02, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • Xv6FileSystemZhewenSong11/28/2017

  • FileSystemLayoutinxv6

    Unused | Superblock | Inodes ... | Unused | Bitmap | Data ...

  • Inode ofaregularfileinxv6

    type = 2majorminornlinksizeaddr 1...

    addr 12indirect addr 1

    ...addr 128

    data

    data

    data

    data

    ...

    64 Bytes512 Bytes

    512 Bytes

    What’sthemaximumpossiblesizeofaregularfile?

    ...

  • Inode ofadirectoryinxv6

    type = 1majorminornlinksizeaddr 1...

    addr 12indirect addr 1

    ...addr 128

    dirent 1...

    dirent 32

    dirent 1...

    dirent 32

    dirent 1...

    dirent 32

    dirent 1...

    dirent 32

    ...

    ...

    64 Bytes512 Bytes

    512 Bytes

    Howmanyfiles/subdirectoriescanadirectoryhaveatmost?

  • Bitmapinxv6

    • Eachbitinthebitmapisassociatedwithablock,NOTaninode.• Althoughtheveryfirstblockisunused,itisalwaysmarkedas1inthefirstbitofthebitmap,andsoarealltheblockswheretheinodes andbitmapitselfreside.• Bitmapisgroupedinbyte.• Intelx86processorsuselittle-endian.• Example:• ff c2 => 1111 1111 1100 0010

    7 6 5 4 3 2 1 0 | 15 14 13 12 11 10 9 8

  • Demos

    • Howtobuildyourownfilesystemimageandreflectinxv6• Closerlookatmkfs.c

    • Howxv6fileschangetheimage• Closerlookatfs.img with xxd• Sometrickseditingfileimageswithvim:

    • :%!xxd toopentheimage;:%!xxd –r tosavechanges

    • Howtoreadimage?– mmap()!

  • Demos• UsingGDB,gothroughtheentirewritesystemcall.• Keymethodstounderstand:

    • writei() in kernel/sysfile.c• bmap() inkernel/fs.c• bread(), bwrite() in kernel/bio.c

    • Howdoesxv6normallyhandlelargefiles?• Whatdowedotohandlesmallfileshere?