Lines Matching refs:rmtfd

24 struct rmtfd {  struct
47 static struct rmtfd rmtfds[MAX_CALLERS]; argument
49 static int storage_populate_shadow_buf(struct rmtfd *rmtfd, const char *file);
75 struct rmtfd *storage_open(unsigned node, const char *path) in storage_open()
79 struct rmtfd *rmtfd = NULL; in storage_open() local
106 rmtfd = &rmtfds[i]; in storage_open()
110 if (!rmtfd) { in storage_open()
132 rmtfd->fd = fd; in storage_open()
133 rmtfd->shadow_len = 0; in storage_open()
135 ret = storage_populate_shadow_buf(rmtfd, fspath); in storage_open()
145 rmtfd->node = node; in storage_open()
146 rmtfd->partition = part; in storage_open()
148 return rmtfd; in storage_open()
151 void storage_close(struct rmtfd *rmtfd) in storage_close() argument
153 close(rmtfd->fd); in storage_close()
154 rmtfd->fd = -1; in storage_close()
156 free(rmtfd->shadow_buf); in storage_close()
157 rmtfd->shadow_buf = NULL; in storage_close()
158 rmtfd->shadow_len = 0; in storage_close()
160 rmtfd->partition = NULL; in storage_close()
163 struct rmtfd *storage_get(unsigned node, int caller_id) in storage_get()
165 struct rmtfd *rmtfd; in storage_get() local
170 rmtfd = &rmtfds[caller_id]; in storage_get()
171 if (rmtfd->node != node) in storage_get()
174 return rmtfd; in storage_get()
177 int storage_get_caller_id(const struct rmtfd *rmtfd) in storage_get_caller_id() argument
179 return rmtfd->id; in storage_get_caller_id()
182 int storage_get_error(const struct rmtfd *rmtfd) in storage_get_error() argument
184 return rmtfd->dev_error; in storage_get_error()
197 ssize_t storage_pread(const struct rmtfd *rmtfd, void *buf, size_t nbyte, off_t offset) in storage_pread() argument
202 n = pread(rmtfd->fd, buf, nbyte, offset); in storage_pread()
204 n = MIN(nbyte, rmtfd->shadow_len - offset); in storage_pread()
206 memcpy(buf, (char*)rmtfd->shadow_buf + offset, n); in storage_pread()
217 ssize_t storage_pwrite(struct rmtfd *rmtfd, const void *buf, size_t nbyte, off_t offset) in storage_pwrite() argument
223 return pwrite(rmtfd->fd, buf, nbyte, offset); in storage_pwrite()
231 if (new_len > rmtfd->shadow_len) { in storage_pwrite()
232 new_buf = realloc(rmtfd->shadow_buf, new_len); in storage_pwrite()
238 rmtfd->shadow_buf = new_buf; in storage_pwrite()
239 rmtfd->shadow_len = new_len; in storage_pwrite()
242 memcpy((char*)rmtfd->shadow_buf + offset, buf, nbyte); in storage_pwrite()
247 static int storage_populate_shadow_buf(struct rmtfd *rmtfd, const char *file) in storage_populate_shadow_buf() argument
279 rmtfd->shadow_buf = buf; in storage_populate_shadow_buf()
280 rmtfd->shadow_len = n; in storage_populate_shadow_buf()