《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 regels
921 B

12 jaren geleden
  1. #ifndef __KERN_FS_IOBUF_H__
  2. #define __KERN_FS_IOBUF_H__
  3. #include <defs.h>
  4. /*
  5. * iobuf is a buffer Rd/Wr status record
  6. */
  7. struct iobuf {
  8. void *io_base; // the base addr of buffer (used for Rd/Wr)
  9. off_t io_offset; // current Rd/Wr position in buffer, will have been incremented by the amount transferred
  10. size_t io_len; // the length of buffer (used for Rd/Wr)
  11. size_t io_resid; // current resident length need to Rd/Wr, will have been decremented by the amount transferred.
  12. };
  13. #define iobuf_used(iob) ((size_t)((iob)->io_len - (iob)->io_resid))
  14. struct iobuf *iobuf_init(struct iobuf *iob, void *base, size_t len, off_t offset);
  15. int iobuf_move(struct iobuf *iob, void *data, size_t len, bool m2b, size_t *copiedp);
  16. int iobuf_move_zeros(struct iobuf *iob, size_t len, size_t *copiedp);
  17. void iobuf_skip(struct iobuf *iob, size_t n);
  18. #endif /* !__KERN_FS_IOBUF_H__ */