proxy: DRY up some code

This commit is contained in:
nick
2013-06-18 16:58:39 +01:00
parent b14bba36ec
commit 2156d06368
4 changed files with 139 additions and 174 deletions

View File

@@ -1,13 +1,23 @@
#ifndef __IOUTIL_H
#define __IOUTIL_H
#include <sys/types.h>
struct iobuf {
unsigned char *buf;
size_t size;
size_t needle;
};
ssize_t iobuf_read( int fd, struct iobuf* iobuf, size_t default_size );
ssize_t iobuf_write( int fd, struct iobuf* iobuf );
#include "serve.h"
struct bitset_mapping; /* don't need whole of bitset.h here */
/** Scan the file opened in ''fd'', set bits in ''allocation_map'' that
* correspond to which blocks are physically allocated on disc (or part-
* allocated). If the OS represents allocated blocks at a finer resolution
* than you've asked for, any block or part block will count as "allocated"
* allocated). If the OS represents allocated blocks at a finer resolution
* than you've asked for, any block or part block will count as "allocated"
* with the corresponding bit set. Returns 1 if successful, 0 otherwise.
*/
int build_allocation_map(struct bitset_mapping* allocation_map, int fd);