-
Notifications
You must be signed in to change notification settings - Fork 0
/
logfs.h
65 lines (52 loc) · 1.5 KB
/
logfs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Tony Givargis
* Copyright (C), 2023
* University of California, Irvine
*
* CS 238P - Operating Systems
* logfs.h
*/
#ifndef _LOGFS_H_
#define _LOGFS_H_
#include "system.h"
struct logfs;
/**
* Opens the block device specified in pathname for buffered I/O using an
* append only log structure.
*
* pathname: the pathname of the block device
*
* return: an opaque handle or NULL on error
*/
struct logfs *logfs_open(const char *pathname);
/**
* Closes a previously opened logfs handle.
*
* logfs: an opaque handle previously obtained by calling logfs_open()
*
* Note: logfs may be NULL.
*/
void logfs_close(struct logfs *logfs);
/**
* Random read of len bytes at location specified in off from the logfs.
*
* logfs: an opaque handle previously obtained by calling logfs_open()
* buf : a region of memory large enough to receive len bytes
* off : the starting byte offset
* len : the number of bytes to read
*
* return: 0 on success, otherwise error
*/
int logfs_read(struct logfs *logfs, void *buf, uint64_t off, size_t len);
/**
* Append len bytes to the logfs.
*
* logfs: an opaque handle previously obtained by calling logfs_open()
* buf : a region of memory holding the len bytes to be written
* len : the number of bytes to write
*
* return: 0 on success, otherwise error
*/
int logfs_append(struct logfs *logfs, const void *buf, uint64_t len);
uint64_t logfs_size(struct logfs *logfs);
#endif /* _LOGFS_H_ */