minix/minix/include/minix/libminixfs.h
David van Moolenbroek 6c46a77d95 libminixfs: better support for read errors and EOF
- The lmfs_get_block*(3) API calls may now return an error.  The idea
  is to encourage a next generation of file system services to do a
  better job at dealing with block read errors than the MFS-derived
  implementations do.  These existing file systems have been changed
  to panic immediately upon getting a block read error, in order to
  let unchecked errors cause corruption.  Note that libbdev already
  retries failing I/O operations a few times first.

- The libminixfs block device I/O module (bio.c) now deals properly
  with end-of-file conditions on block devices.  Since a device or
  partition size may not be a multiple of the root file system's block
  size, support for partial block retrival has been added, with a new
  internal lmfs_get_partial_block(3) call.  A new test program,
  test85, tests the new handling of EOF conditions when reading,
  writing, and memory-mapping a block device.

Change-Id: I05e35b6b8851488328a2679da635ebba0c6d08ce
2015-08-14 18:39:26 +00:00

67 lines
2.5 KiB
C

/* Prototypes for -lminixfs. */
#ifndef _MINIX_FSLIB_H
#define _MINIX_FSLIB_H
#include <minix/fsdriver.h>
struct buf {
/* Data portion of the buffer. */
void *data;
/* Header portion of the buffer - internal to libminixfs. */
struct buf *lmfs_next; /* used to link all free bufs in a chain */
struct buf *lmfs_prev; /* used to link all free bufs the other way */
struct buf *lmfs_hash; /* used to link bufs on hash chains */
dev_t lmfs_dev; /* major | minor device where block resides */
block64_t lmfs_blocknr; /* block number of its (minor) device */
char lmfs_count; /* number of users of this buffer */
char lmfs_needsetcache; /* to be identified to VM */
size_t lmfs_bytes; /* size of this block (allocated and used) */
u32_t lmfs_flags; /* Flags shared between VM and FS */
/* If any, which inode & offset does this block correspond to?
* If none, VMC_NO_INODE
*/
ino_t lmfs_inode;
u64_t lmfs_inode_offset;
};
void lmfs_markdirty(struct buf *bp);
void lmfs_markclean(struct buf *bp);
int lmfs_isclean(struct buf *bp);
dev_t lmfs_dev(struct buf *bp);
int lmfs_bufs_in_use(void);
int lmfs_nr_bufs(void);
void lmfs_flushall(void);
void lmfs_flushdev(dev_t dev);
size_t lmfs_fs_block_size(void);
void lmfs_may_use_vmcache(int);
void lmfs_set_blocksize(size_t blocksize);
void lmfs_buf_pool(int new_nr_bufs);
int lmfs_get_block(struct buf **bpp, dev_t dev, block64_t block, int how);
int lmfs_get_block_ino(struct buf **bpp, dev_t dev, block64_t block, int how,
ino_t ino, u64_t off);
void lmfs_put_block(struct buf *bp);
void lmfs_free_block(dev_t dev, block64_t block);
void lmfs_zero_block_ino(dev_t dev, ino_t ino, u64_t off);
void lmfs_invalidate(dev_t device);
void lmfs_rw_scattered(dev_t, struct buf **, int, int);
void lmfs_setquiet(int q);
void lmfs_set_blockusage(fsblkcnt_t btotal, fsblkcnt_t bused);
void lmfs_change_blockusage(int delta);
/* get_block arguments */
#define NORMAL 0 /* forces get_block to do disk read */
#define NO_READ 1 /* prevents get_block from doing disk read */
#define PREFETCH 2 /* tells get_block not to read or mark dev */
#define PEEK 3 /* returns ENOENT if not in cache */
/* Block I/O helper functions. */
void lmfs_driver(dev_t dev, char *label);
ssize_t lmfs_bio(dev_t dev, struct fsdriver_data *data, size_t bytes,
off_t pos, int call);
void lmfs_bflush(dev_t dev);
#endif /* _MINIX_FSLIB_H */