I am working on a FUSE implementation for FAT32 under Linux (I know this is already available in the Linux Kernel, but this is a school assignment).
The FAT32 f开发者_Python百科ilesystem is created with the mkfs.msdos
command, which I will later map into memory with posix_madvise
, or use an unlocked stream by means of posix_fadvise
.
I am not sure what should I base my choice on, I mean, what the pros and cons of each method are (in terms of performance, memory usage, etc). I have seen a few examples out there which combine the use of madvise
with mmap
, but no information was provided as to whether fadvise
should be used with mmap
too, or, to start with, the difference between the fadvise
/madvise
and POSIX implementations posix_fadvise
/posix_madvise
.
Any point in the right direction will be greatly appreciated.
Unless you want to limit yourself to ~2.5 GB filesystems or requiring a 64-bit machine, your choices are to use mmap
and dynamically manage what part of the filesystem you keep mapped, or use normal read/write operations. I would probably go for the latter. mmap
is overrated as a performance optimization, and has drawbacks like filling up your virtual address space, so I would tend to only use mmap
when you really need to treat a file as memory - for instance, storing process-shared synchronization objects, executable code, or large data you want to feed to an API that only accepts in-memory data (for example, qsort
).
精彩评论