benavento / mac9p

9P Kernel Extension for MacOS
95 stars 8 forks source link

Write padded to 4096 bytes #3

Open kennylevinsen opened 8 years ago

kennylevinsen commented 8 years ago

Open a new file for writing with O_WRONLY | O_CREATE | O_APPEND, and write a few bytes to it. The write will be as intended. Then, do the same again. This time, the write will be padded with 0's up to 4096 bytes.

I have traced that the write ends up in vnop_write_9p, using the cluster_write branch. At this point, size of write seems sane. As a result, one ends up in vnop_strategy_9p. Here, the provided block buffer... thing has a count of 4096, with size, dirtyend and dirtyoff all being 0.

This is seen on el capitan.

kennylevinsen commented 8 years ago

The temporary fix I am currently deploying is to remove all cluster and mmap functionality.

I don't understand the VFS layer well enough to figure out how to retrieve the intended length from vnop_strategy. Then again, the strategy concept seems a bit silly in 9P context, and the NFS implementation doesn't use it, just implementing pagein/pageout in some other way that I haven't had time to understand yet.