shim_fs.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* Copyright (C) 2014 Stony Brook University
  4. This file is part of Graphene Library OS.
  5. Graphene Library OS is free software: you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation, either version 3 of the
  8. License, or (at your option) any later version.
  9. Graphene Library OS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * shim_fs.h
  17. *
  18. * Definitions of types and functions for file system bookkeeping.
  19. */
  20. #ifndef _SHIM_FS_H_
  21. #define _SHIM_FS_H_
  22. #include <stdbool.h>
  23. #include <shim_types.h>
  24. #include <shim_defs.h>
  25. #include <shim_handle.h>
  26. #include <shim_utils.h>
  27. #include <pal.h>
  28. #include <list.h>
  29. struct shim_handle;
  30. #define FS_POLL_RD 0x01
  31. #define FS_POLL_WR 0x02
  32. #define FS_POLL_ER 0x04
  33. #define FS_POLL_SZ 0x08
  34. struct shim_fs_ops {
  35. /* mount: moun an uri to the certain location */
  36. int (*mount) (const char * uri, const char * root, void ** mount_data);
  37. int (*unmount) (void * mount_data);
  38. /* close: clean up the file state inside the handle */
  39. int (*close) (struct shim_handle * hdl);
  40. /* read: the content from the file opened as handle */
  41. int (*read) (struct shim_handle * hdl, void * buf, size_t count);
  42. /* write: the content from the file opened as handle */
  43. int (*write) (struct shim_handle * hdl, const void * buf, size_t count);
  44. /* mmap: mmap handle to address */
  45. int (*mmap) (struct shim_handle * hdl, void ** addr, size_t size,
  46. int prot, int flags, off_t offset);
  47. /* flush: flush out user buffer */
  48. int (*flush) (struct shim_handle * hdl);
  49. /* seek: the content from the file opened as handle */
  50. int (*seek) (struct shim_handle * hdl, off_t offset, int wence);
  51. /* move, copy: rename or duplicate the file */
  52. int (*move) (const char * trim_old_name, const char * trim_new_name);
  53. int (*copy) (const char * trim_old_name, const char * trim_new_name);
  54. /* Returns 0 on success, -errno on error */
  55. int (*truncate) (struct shim_handle * hdl, uint64_t len);
  56. /* hstat: get status of the file */
  57. int (*hstat) (struct shim_handle * hdl, struct stat * buf);
  58. /* setflags: set flags of the file */
  59. int (*setflags) (struct shim_handle * hdl, int flags);
  60. /* hput: delete the handle and close the PAL handle. */
  61. void (*hput) (struct shim_handle * hdl);
  62. /* lock and unlock the file */
  63. int (*lock) (const char * trim_name);
  64. int (*unlock) (const char * trim_name);
  65. /* lock and unlock the file system */
  66. int (*lockfs) (void);
  67. int (*unlockfs) (void);
  68. /* checkout/reowned/checkin a single handle for migration */
  69. int (*checkout) (struct shim_handle * hdl);
  70. int (*checkin) (struct shim_handle * hdl);
  71. /* poll a single handle */
  72. /* POLL_RD|POLL_WR: return POLL_RD|POLL_WR for readable|writeable,
  73. POLL_ER for failure, -EAGAIN for unknown. */
  74. /* POLL_SZ: return total size */
  75. int (*poll) (struct shim_handle * hdl, int poll_type);
  76. /* checkpoint/migrate the filesystem */
  77. int (*checkpoint) (void ** checkpoint, void * mount_data);
  78. int (*migrate) (void * checkpoint, void ** mount_data);
  79. };
  80. #define DENTRY_VALID 0x0001 /* this dentry is verified to be valid */
  81. #define DENTRY_NEGATIVE 0x0002 /* negative, recently deleted */
  82. #define DENTRY_RECENTLY 0x0004 /* recently used */
  83. #define DENTRY_PERSIST 0x0008 /* added as a persistent dentry */
  84. #define DENTRY_HASHED 0x0010 /* added in the dcache */
  85. #define DENTRY_MOUNTPOINT 0x0040 /* this dentry is a mount point */
  86. #define DENTRY_ISLINK 0x0080 /* this dentry is a link */
  87. #define DENTRY_ISDIRECTORY 0x0100 /* this dentry is a directory */
  88. #define DENTRY_LOCKED 0x0200 /* locked by mountpoints at children */
  89. /* These flags are not used */
  90. //#define DENTRY_REACHABLE 0x0400 /* permission checked to be reachable */
  91. //#define DENTRY_UNREACHABLE 0x0800 /* permission checked to be unreachable */
  92. #define DENTRY_LISTED 0x1000 /* children in directory listed */
  93. #define DENTRY_INO_UPDATED 0x2000 /* ino updated */
  94. #define DENTRY_ANCESTOR 0x4000 /* Auto-generated dentry to connect a mount
  95. * point in the manifest to the root, when
  96. * one or more intermediate directories do
  97. * not exist on the underlying FS. The
  98. * semantics of subsequent changes to such
  99. * directories (or attempts to really
  100. * create them) are not currently
  101. * well-defined. */
  102. // Catch memory corruption issues by checking for invalid state values
  103. #define DENTRY_INVALID_FLAGS ~0x7FFF
  104. #define DCACHE_HASH_SIZE 1024
  105. #define DCACHE_HASH(hash) ((hash) & (DCACHE_HASH_SIZE - 1))
  106. DEFINE_LIST(shim_dentry);
  107. DEFINE_LISTP(shim_dentry);
  108. struct shim_dentry {
  109. int state; /* flags for managing state */
  110. struct shim_mount * fs; /* this dentry's mounted fs */
  111. struct shim_qstr rel_path; /* the path is relative to
  112. its mount point */
  113. struct shim_qstr name; /* caching the file's name. */
  114. /* DEP 6/16/17: For now, let's try not hashing; I suspect it is
  115. * overkill for most purposes. I'll leave the field here for now,
  116. * but propose we move to a per-directory table to accelerate lookups,
  117. * rather than a global table, since this just supports one process.
  118. */
  119. LIST_TYPE(shim_dentry) hlist; /* to resolve collisions in
  120. the hash table */
  121. LIST_TYPE(shim_dentry) list; /* put dentry to different list
  122. according to its availability,
  123. persistent or freeable */
  124. struct shim_dentry * parent;
  125. int nchildren;
  126. LISTP_TYPE(shim_dentry) children; /* These children and siblings link */
  127. LIST_TYPE(shim_dentry) siblings;
  128. struct shim_mount * mounted;
  129. void * data;
  130. unsigned long ino;
  131. mode_t type;
  132. mode_t mode;
  133. LOCKTYPE lock;
  134. REFTYPE ref_count;
  135. };
  136. struct shim_d_ops {
  137. /* open: provide a filename relative to the mount point and flags,
  138. modify the shim handle, file_data is "inode" equivalent */
  139. int (*open) (struct shim_handle * hdl, struct shim_dentry * dent,
  140. int flags);
  141. /* look up dentry and allocate internal data.
  142. *
  143. * On a successful lookup (non-error, can be negative),
  144. * this function should call get_new_dentry(), populating additional fields,
  145. * and storing the new dentry in dent.
  146. *
  147. * Maybe drop force?
  148. */
  149. int (*lookup) (struct shim_dentry * dent, bool force);
  150. /* this is to check file type and access, returning the stat.st_mode */
  151. int (*mode) (struct shim_dentry * dent, mode_t * mode, bool force);
  152. /* detach internal data from dentry */
  153. int (*dput) (struct shim_dentry * dent);
  154. /* create a dentry inside a directory */
  155. int (*creat) (struct shim_handle * hdl, struct shim_dentry * dir,
  156. struct shim_dentry * dent, int flags, mode_t mode);
  157. /* unlink a dentry inside a directory */
  158. int (*unlink) (struct shim_dentry * dir, struct shim_dentry * dent);
  159. /* create a directory inside a directory */
  160. int (*mkdir) (struct shim_dentry * dir, struct shim_dentry * dent,
  161. mode_t mode);
  162. /* stat: get status of the file */
  163. int (*stat) (struct shim_dentry * dent, struct stat * buf);
  164. /* extracts the symlink name and saves in link */
  165. int (*follow_link) (struct shim_dentry * dent, struct shim_qstr * link);
  166. /* set up symlink name to a dentry */
  167. int (*set_link) (struct shim_dentry * dent, const char * link);
  168. /* change the mode or owner of a dentry */
  169. int (*chmod) (struct shim_dentry * dent, mode_t mode);
  170. int (*chown) (struct shim_dentry * dent, int uid, int gid);
  171. /* change the name of a dentry */
  172. int (*rename) (struct shim_dentry * old, struct shim_dentry * new);
  173. /* readdir: given the path relative to the mount point, read the childs
  174. into the the buffer. This call always returns everything under
  175. the directory in one big buffer; you do not need to try again
  176. or keep a cursor in the directory. You do need to free the
  177. returned buffer. */
  178. int (*readdir) (struct shim_dentry * dent, struct shim_dirent ** dirent);
  179. };
  180. #define MAX_PATH 4096
  181. #define MAX_FILENAME 255
  182. DEFINE_LIST(shim_mount);
  183. struct shim_mount {
  184. char type[8]; // Null-terminated.
  185. struct shim_dentry * mount_point;
  186. struct shim_qstr path;
  187. struct shim_qstr uri;
  188. struct shim_fs_ops * fs_ops;
  189. struct shim_d_ops * d_ops;
  190. struct shim_dentry * root;
  191. void * data;
  192. void * cpdata;
  193. size_t cpsize;
  194. REFTYPE ref_count;
  195. LIST_TYPE(shim_mount) hlist;
  196. LIST_TYPE(shim_mount) list;
  197. };
  198. extern struct shim_dentry * dentry_root;
  199. #define LOOKUP_FOLLOW 001
  200. #define LOOKUP_DIRECTORY 002
  201. #define LOOKUP_CONTINUE 004 // No longer needed
  202. #define LOOKUP_PARENT 010 // Not sure we need this
  203. #define F_OK 0
  204. // XXX: Duplicate definition; should probably weed out includes of host system
  205. //include of unistd.h in future work
  206. //#define R_OK 001
  207. //#define W_OK 002
  208. //#define X_OK 004
  209. #define MAY_EXEC 001
  210. #define MAY_WRITE 002
  211. #define MAY_READ 004
  212. #if 0
  213. #define MAY_APPEND 010
  214. #endif
  215. #define NO_MODE ((mode_t) -1)
  216. #define ACC_MODE(x) ((((x) == O_RDONLY || (x) == O_RDWR) ? MAY_READ : 0) | \
  217. (((x) == O_WRONLY || (x) == O_RDWR) ? MAY_WRITE : 0))
  218. #define LOOKUP_OPEN 0100 // Appears to be ignored
  219. #define LOOKUP_CREATE 0200
  220. #define LOOKUP_ACCESS 0400 // Appears to be ignored
  221. #define LOOKUP_SYNC (LOOKUP_OPEN|LOOKUP_CREATE|LOOKUP_ACCESS)
  222. enum lookup_type {
  223. LAST_NORM,
  224. LAST_ROOT,
  225. LAST_DOT,
  226. LAST_DOTDOT,
  227. LAST_BIND
  228. };
  229. struct lookup {
  230. struct shim_dentry * dentry;
  231. struct shim_mount * mount;
  232. const char * last;
  233. int depth;
  234. int flags;
  235. enum lookup_type last_type;
  236. };
  237. /* initialization for fs and mounts */
  238. int init_fs (void);
  239. int init_mount_root (void);
  240. int init_mount (void);
  241. /* path utilities */
  242. const char * get_file_name (const char * path, size_t len);
  243. /* file system operations */
  244. int mount_fs (const char * mount_type, const char * mount_uri,
  245. const char * mount_point, struct shim_dentry *parent,
  246. struct shim_dentry **dentp, bool make_ancestor);
  247. int unmount_fs (const char * mount_point);
  248. int search_builtin_fs (const char * type, struct shim_mount ** fs);
  249. void get_mount (struct shim_mount * mount);
  250. void put_mount (struct shim_mount * mount);
  251. struct shim_mount * find_mount_from_uri (const char * uri);
  252. #include <shim_utils.h>
  253. static inline void set_handle_fs (struct shim_handle * hdl,
  254. struct shim_mount * fs)
  255. {
  256. get_mount(fs);
  257. hdl->fs = fs;
  258. memcpy(hdl->fs_type, fs->type, sizeof(hdl->fs_type));
  259. }
  260. int walk_mounts (int (*walk) (struct shim_mount * mount, void * arg),
  261. void * arg);
  262. /* functions for dcache supports */
  263. int init_dcache (void);
  264. extern LOCKTYPE dcache_lock;
  265. /* check permission (specified by mask) of a dentry. If force is not set,
  266. * permission is considered granted on invalid dentries */
  267. /* Assume caller has acquired dcache_lock */
  268. int permission (struct shim_dentry * dent, int mask, bool force);
  269. /* This function looks up a single dentry based on its parent dentry pointer
  270. * and the name. Namelen is the length of char * name.
  271. * The dentry is returned in pointer *new.
  272. *
  273. * The force flag causes the libOS to query the underlying file system for the
  274. * existence of the dentry, whereas without force, a negative dentry is
  275. * treated as definitive. In some cases, this can be elided as an
  276. * optimization.
  277. *
  278. * The caller should hold the dcache_lock.
  279. */
  280. int lookup_dentry (struct shim_dentry * parent, const char * name, int namelen,
  281. bool force, struct shim_dentry ** new, struct shim_mount * fs);
  282. /* Looks up path under start dentry. Saves in dent.
  283. *
  284. * Assumes dcache_lock is held; main difference from path_lookupat is that
  285. * dcache_lock is not released on return.
  286. *
  287. * The refcount is dropped by one on the returned dentry.
  288. *
  289. * The make_ancestor flag creates pseudo-dentries for any parent paths that
  290. * are not in cache and do not exist on the underlying file system. This is
  291. * intended for use only in setting up the file system view specified in the manifest.
  292. *
  293. * If the file isnt' found, returns -ENOENT.
  294. *
  295. * If the LOOKUP_DIRECTORY flag is set, and the found file isn't a directory,
  296. * returns -ENOTDIR.
  297. */
  298. int __path_lookupat (struct shim_dentry * start, const char * path, int flags,
  299. struct shim_dentry ** dent, int link_depth,
  300. struct shim_mount *fs, bool make_ancestor);
  301. /* Just wraps __path_lookupat, but also acquires and releases the dcache_lock.
  302. */
  303. int path_lookupat (struct shim_dentry * start, const char * name, int flags,
  304. struct shim_dentry ** dent, struct shim_mount *fs);
  305. /* This function initializes dir to before a search, to either point
  306. * to the current working directory (if dfd == AT_FDCWD), or to the handle pointed to by dfd,
  307. * depending on the argument.
  308. *
  309. * Returns -EBADF if dfd is <0 or not a valid handle.
  310. * Returns -ENOTDIR if dfd is not a directory.
  311. */
  312. int path_startat (int dfd, struct shim_dentry ** dir);
  313. /* Open path with given flags, in mode, similar to Unix open.
  314. *
  315. * The start dentry specifies where to begin the search.
  316. * hdl is an optional argument; if passed in, it is initialized to
  317. * refer to the opened path.
  318. *
  319. * The result is stored in dent.
  320. */
  321. int open_namei (struct shim_handle * hdl, struct shim_dentry * start,
  322. const char * path, int flags, int mode,
  323. struct shim_dentry ** dent);
  324. /* This function calls the low-level file system to do the work
  325. * of opening file indicated by dent, and initializing it in hdl.
  326. * Flags are standard open flags.
  327. *
  328. * If O_TRUNC is specified, this function is responsible for calling
  329. * the underlying truncate function.
  330. */
  331. int dentry_open (struct shim_handle * hdl, struct shim_dentry * dent,
  332. int flags);
  333. /* This function enumerates a directory and caches the results in the dentry.
  334. *
  335. * Input: A dentry for a directory in the DENTRY_ISDIRECTORY and not in the
  336. * DENTRY_LISTED state. The dentry DENTRY_LISTED flag is set upon success.
  337. *
  338. * Return value: 0 on success, <0 on error
  339. */
  340. int list_directory_dentry (struct shim_dentry *dir);
  341. /* This function caches the contents of a directory (dent), already
  342. * in the listed state, in a buffer associated with a handle (hdl).
  343. *
  344. * This function should only be called once on a handle.
  345. *
  346. * Returns 0 on success, <0 on failure.
  347. */
  348. int list_directory_handle (struct shim_dentry *dent, struct shim_handle *hdl );
  349. /* Increment the reference count on dent */
  350. void get_dentry (struct shim_dentry * dent);
  351. /* Decrement the reference count on dent */
  352. void put_dentry (struct shim_dentry * dent);
  353. static_always_inline
  354. void fast_pathcpy (char * dst, const char * src, int size, char ** ptr)
  355. {
  356. char * d = dst;
  357. const char * s = src;
  358. for (int i = 0 ; i < size ; i++, s++, d++)
  359. *d = *s;
  360. *ptr = d;
  361. }
  362. static_always_inline
  363. char * dentry_get_path (struct shim_dentry * dent, bool on_stack,
  364. int * sizeptr)
  365. {
  366. struct shim_mount * fs = dent->fs;
  367. char * buffer, * c;
  368. int bufsize = dent->rel_path.len + 1;
  369. if (fs)
  370. bufsize += fs->path.len + 1;
  371. if (on_stack) {
  372. c = buffer = __alloca(bufsize);
  373. } else {
  374. if (!(c = buffer = malloc(bufsize)))
  375. return NULL;
  376. }
  377. if (fs && !qstrempty(&fs->path))
  378. fast_pathcpy(c, qstrgetstr(&fs->path), fs->path.len, &c);
  379. if (dent->rel_path.len) {
  380. const char * path = qstrgetstr(&dent->rel_path);
  381. int len = dent->rel_path.len;
  382. if (c > buffer && *(c - 1) == '/') {
  383. if (*path == '/')
  384. path++;
  385. } else {
  386. if (*path != '/')
  387. *(c++) = '/';
  388. }
  389. fast_pathcpy(c, path, len, &c);
  390. }
  391. if (sizeptr)
  392. *sizeptr = c - buffer;
  393. *c = 0;
  394. return buffer;
  395. }
  396. static_always_inline
  397. const char * dentry_get_name (struct shim_dentry * dent)
  398. {
  399. return qstrgetstr(&dent->name);
  400. }
  401. /* Allocate and initialize a new dentry for path name, under
  402. * parent. Return the dentry.
  403. *
  404. * mount is the mountpoint the dentry is under; this is typically
  405. * the parent->fs, but is passed explicitly for initializing
  406. * the dentry of a mountpoint.
  407. *
  408. * If hashptr is passed (as an optimization), this is a hash
  409. * of the name.
  410. *
  411. * If parent is non-null, the ref count is 1; else it is zero.
  412. *
  413. * This function also sets up both a name and a relative path
  414. */
  415. struct shim_dentry * get_new_dentry (struct shim_mount *mount,
  416. struct shim_dentry * parent,
  417. const char * name, int namelen,
  418. HASHTYPE * hashptr);
  419. /* This function searches for name/namelen (as the relative path;
  420. * path/pathlen is the fully-qualified path),
  421. * under parent dentry (start).
  422. *
  423. * If requested, the expected hash of the dentry is returned in hashptr,
  424. * primarily so that the hashing can be reused to add the dentry later.
  425. *
  426. * The reference count on the found dentry is incremented by one.
  427. *
  428. * Used only by shim_namei.c
  429. */
  430. struct shim_dentry *
  431. __lookup_dcache (struct shim_dentry * start, const char * name, int namelen,
  432. const char * path, int pathlen, HASHTYPE * hashptr);
  433. /* This function recursively deletes and frees all dentries under root
  434. *
  435. * XXX: Current code doesn't do a free..
  436. */
  437. int __del_dentry_tree(struct shim_dentry * root);
  438. /* XXX: Future work: current dcache never shrinks. Would be nice
  439. * to be able to do something like LRU under space pressure, although
  440. * for a single app, this may be over-kill. */
  441. /* hashing utilities */
  442. #define MOUNT_HASH_BYTE 1
  443. #define MOUNT_HASH_WIDTH 8
  444. #define MOUNT_HASH_SIZE 256
  445. #define MOUNT_HASH(hash) ((hash) & (MOUNT_HASH_SIZE - 1))
  446. HASHTYPE hash_path (const char * path, int size,
  447. const char * sep);
  448. HASHTYPE hash_parent_path (HASHTYPE hbuf, const char * name,
  449. int * size, const char * sep);
  450. HASHTYPE rehash_name (HASHTYPE parent_hbuf,
  451. const char * name, int size);
  452. HASHTYPE rehash_path (HASHTYPE ancester_hbuf,
  453. const char * path, int size, const char * sep);
  454. extern struct shim_fs_ops chroot_fs_ops;
  455. extern struct shim_d_ops chroot_d_ops;
  456. extern struct shim_fs_ops str_fs_ops;
  457. extern struct shim_d_ops str_d_ops;
  458. extern struct shim_fs_ops dev_fs_ops;
  459. extern struct shim_d_ops dev_d_ops;
  460. extern struct shim_fs_ops config_fs_ops;
  461. extern struct shim_d_ops config_d_ops;
  462. extern struct shim_fs_ops proc_fs_ops;
  463. extern struct shim_d_ops proc_d_ops;
  464. extern struct shim_mount chroot_builtin_fs;
  465. extern struct shim_mount pipe_builtin_fs;
  466. extern struct shim_mount socket_builtin_fs;
  467. extern struct shim_mount epoll_builtin_fs;
  468. /* proc file system */
  469. struct proc_nm_ops {
  470. int (*match_name) (const char * name);
  471. int (*list_name) (const char * name, struct shim_dirent ** buf,
  472. int count);
  473. };
  474. struct proc_fs_ops {
  475. int (*open) (struct shim_handle * hdl, const char * name, int flags);
  476. int (*mode) (const char * name, mode_t * mode);
  477. int (*stat) (const char * name, struct stat * buf);
  478. int (*follow_link) (const char * name, struct shim_qstr * link);
  479. };
  480. struct proc_dir;
  481. struct proc_ent {
  482. const char * name; /* a proc_callback should at least
  483. have a name or nm_ops.
  484. Otherwise, it is a NULL-end. */
  485. const struct proc_nm_ops * nm_ops;
  486. const struct proc_fs_ops * fs_ops;
  487. const struct proc_dir * dir;
  488. };
  489. struct proc_dir {
  490. int size;
  491. const struct proc_ent ent[];
  492. };
  493. /* string-type file system */
  494. int str_add_dir (const char * path, mode_t mode, struct shim_dentry ** dent);
  495. int str_add_file (const char * path, mode_t mode, struct shim_dentry ** dent);
  496. int str_open (struct shim_handle * hdl, struct shim_dentry * dent, int flags);
  497. int str_dput (struct shim_dentry * dent);
  498. int str_close (struct shim_handle * hdl);
  499. int str_read (struct shim_handle * hdl, void * buf, size_t count);
  500. int str_write (struct shim_handle * hdl, const void * buf, size_t count);
  501. int str_seek (struct shim_handle * hdl, off_t offset, int whence);
  502. int str_flush (struct shim_handle * hdl);
  503. #endif /* _SHIM_FS_H_ */