structbuf{intflags;uintdev;uintsector;structspinlocklock;structsleeplocksleeplock;structbuf*prev;// LRU cache liststructbuf*next;structbuf*qnext;// disk queueuchardata[512];};#define B_VALID 0x1 // buffer has been read from disk#define B_DIRTY 0x2 // buffer needs to be written to disk