9p-proxy.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  1. /*
  2. * 9p Proxy callback
  3. *
  4. * Copyright IBM, Corp. 2011
  5. *
  6. * Authors:
  7. * M. Mohan Kumar <mohan@in.ibm.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2. See
  10. * the COPYING file in the top-level directory.
  11. */
  12. /*
  13. * Not so fast! You might want to read the 9p developer docs first:
  14. * https://wiki.qemu.org/Documentation/9p
  15. */
  16. #include "qemu/osdep.h"
  17. #include <sys/socket.h>
  18. #include <sys/un.h>
  19. #include "9p.h"
  20. #include "qapi/error.h"
  21. #include "qemu/cutils.h"
  22. #include "qemu/error-report.h"
  23. #include "qemu/option.h"
  24. #include "fsdev/qemu-fsdev.h"
  25. #include "9p-proxy.h"
  26. typedef struct V9fsProxy {
  27. int sockfd;
  28. QemuMutex mutex;
  29. struct iovec in_iovec;
  30. struct iovec out_iovec;
  31. } V9fsProxy;
  32. /*
  33. * Return received file descriptor on success in *status.
  34. * errno is also returned on *status (which will be < 0)
  35. * return < 0 on transport error.
  36. */
  37. static int v9fs_receivefd(int sockfd, int *status)
  38. {
  39. struct iovec iov;
  40. struct msghdr msg;
  41. struct cmsghdr *cmsg;
  42. int retval, data, fd;
  43. union MsgControl msg_control;
  44. iov.iov_base = &data;
  45. iov.iov_len = sizeof(data);
  46. memset(&msg, 0, sizeof(msg));
  47. msg.msg_iov = &iov;
  48. msg.msg_iovlen = 1;
  49. msg.msg_control = &msg_control;
  50. msg.msg_controllen = sizeof(msg_control);
  51. do {
  52. retval = recvmsg(sockfd, &msg, 0);
  53. } while (retval < 0 && errno == EINTR);
  54. if (retval <= 0) {
  55. return retval;
  56. }
  57. /*
  58. * data is set to V9FS_FD_VALID, if ancillary data is sent. If this
  59. * request doesn't need ancillary data (fd) or an error occurred,
  60. * data is set to negative errno value.
  61. */
  62. if (data != V9FS_FD_VALID) {
  63. *status = data;
  64. return 0;
  65. }
  66. /*
  67. * File descriptor (fd) is sent in the ancillary data. Check if we
  68. * indeed received it. One of the reasons to fail to receive it is if
  69. * we exceeded the maximum number of file descriptors!
  70. */
  71. for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
  72. if (cmsg->cmsg_len != CMSG_LEN(sizeof(int)) ||
  73. cmsg->cmsg_level != SOL_SOCKET ||
  74. cmsg->cmsg_type != SCM_RIGHTS) {
  75. continue;
  76. }
  77. fd = *((int *)CMSG_DATA(cmsg));
  78. *status = fd;
  79. return 0;
  80. }
  81. *status = -ENFILE; /* Ancillary data sent but not received */
  82. return 0;
  83. }
  84. static ssize_t socket_read(int sockfd, void *buff, size_t size)
  85. {
  86. ssize_t retval, total = 0;
  87. while (size) {
  88. retval = read(sockfd, buff, size);
  89. if (retval == 0) {
  90. return -EIO;
  91. }
  92. if (retval < 0) {
  93. if (errno == EINTR) {
  94. continue;
  95. }
  96. return -errno;
  97. }
  98. size -= retval;
  99. buff += retval;
  100. total += retval;
  101. }
  102. return total;
  103. }
  104. /* Converts proxy_statfs to VFS statfs structure */
  105. static void prstatfs_to_statfs(struct statfs *stfs, ProxyStatFS *prstfs)
  106. {
  107. memset(stfs, 0, sizeof(*stfs));
  108. stfs->f_type = prstfs->f_type;
  109. stfs->f_bsize = prstfs->f_bsize;
  110. stfs->f_blocks = prstfs->f_blocks;
  111. stfs->f_bfree = prstfs->f_bfree;
  112. stfs->f_bavail = prstfs->f_bavail;
  113. stfs->f_files = prstfs->f_files;
  114. stfs->f_ffree = prstfs->f_ffree;
  115. #ifdef CONFIG_DARWIN
  116. /* f_namelen and f_frsize do not exist on Darwin */
  117. stfs->f_fsid.val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU;
  118. stfs->f_fsid.val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU;
  119. #else
  120. stfs->f_fsid.__val[0] = prstfs->f_fsid[0] & 0xFFFFFFFFU;
  121. stfs->f_fsid.__val[1] = prstfs->f_fsid[1] >> 32 & 0xFFFFFFFFU;
  122. stfs->f_namelen = prstfs->f_namelen;
  123. stfs->f_frsize = prstfs->f_frsize;
  124. #endif
  125. }
  126. /* Converts proxy_stat structure to VFS stat structure */
  127. static void prstat_to_stat(struct stat *stbuf, ProxyStat *prstat)
  128. {
  129. memset(stbuf, 0, sizeof(*stbuf));
  130. stbuf->st_dev = prstat->st_dev;
  131. stbuf->st_ino = prstat->st_ino;
  132. stbuf->st_nlink = prstat->st_nlink;
  133. stbuf->st_mode = prstat->st_mode;
  134. stbuf->st_uid = prstat->st_uid;
  135. stbuf->st_gid = prstat->st_gid;
  136. stbuf->st_rdev = prstat->st_rdev;
  137. stbuf->st_size = prstat->st_size;
  138. stbuf->st_blksize = prstat->st_blksize;
  139. stbuf->st_blocks = prstat->st_blocks;
  140. stbuf->st_atime = prstat->st_atim_sec;
  141. stbuf->st_mtime = prstat->st_mtim_sec;
  142. stbuf->st_ctime = prstat->st_ctim_sec;
  143. #ifdef CONFIG_DARWIN
  144. stbuf->st_atimespec.tv_sec = prstat->st_atim_sec;
  145. stbuf->st_mtimespec.tv_sec = prstat->st_mtim_sec;
  146. stbuf->st_ctimespec.tv_sec = prstat->st_ctim_sec;
  147. stbuf->st_atimespec.tv_nsec = prstat->st_atim_nsec;
  148. stbuf->st_mtimespec.tv_nsec = prstat->st_mtim_nsec;
  149. stbuf->st_ctimespec.tv_nsec = prstat->st_ctim_nsec;
  150. #else
  151. stbuf->st_atim.tv_sec = prstat->st_atim_sec;
  152. stbuf->st_mtim.tv_sec = prstat->st_mtim_sec;
  153. stbuf->st_ctim.tv_sec = prstat->st_ctim_sec;
  154. stbuf->st_atim.tv_nsec = prstat->st_atim_nsec;
  155. stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec;
  156. stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec;
  157. #endif
  158. }
  159. /*
  160. * Response contains two parts
  161. * {header, data}
  162. * header.type == T_ERROR, data -> -errno
  163. * header.type == T_SUCCESS, data -> response
  164. * size of errno/response is given by header.size
  165. * returns < 0, on transport error. response is
  166. * valid only if status >= 0.
  167. */
  168. static int v9fs_receive_response(V9fsProxy *proxy, int type,
  169. int *status, void *response)
  170. {
  171. int retval;
  172. ProxyHeader header;
  173. struct iovec *reply = &proxy->in_iovec;
  174. *status = 0;
  175. reply->iov_len = 0;
  176. retval = socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ);
  177. if (retval < 0) {
  178. return retval;
  179. }
  180. reply->iov_len = PROXY_HDR_SZ;
  181. retval = proxy_unmarshal(reply, 0, "dd", &header.type, &header.size);
  182. assert(retval == 4 * 2);
  183. /*
  184. * if response size > PROXY_MAX_IO_SZ, read the response but ignore it and
  185. * return -ENOBUFS
  186. */
  187. if (header.size > PROXY_MAX_IO_SZ) {
  188. int count;
  189. while (header.size > 0) {
  190. count = MIN(PROXY_MAX_IO_SZ, header.size);
  191. count = socket_read(proxy->sockfd, reply->iov_base, count);
  192. if (count < 0) {
  193. return count;
  194. }
  195. header.size -= count;
  196. }
  197. *status = -ENOBUFS;
  198. return 0;
  199. }
  200. retval = socket_read(proxy->sockfd,
  201. reply->iov_base + PROXY_HDR_SZ, header.size);
  202. if (retval < 0) {
  203. return retval;
  204. }
  205. reply->iov_len += header.size;
  206. /* there was an error during processing request */
  207. if (header.type == T_ERROR) {
  208. int ret;
  209. ret = proxy_unmarshal(reply, PROXY_HDR_SZ, "d", status);
  210. assert(ret == 4);
  211. return 0;
  212. }
  213. switch (type) {
  214. case T_LSTAT: {
  215. ProxyStat prstat;
  216. retval = proxy_unmarshal(reply, PROXY_HDR_SZ,
  217. "qqqdddqqqqqqqqqq", &prstat.st_dev,
  218. &prstat.st_ino, &prstat.st_nlink,
  219. &prstat.st_mode, &prstat.st_uid,
  220. &prstat.st_gid, &prstat.st_rdev,
  221. &prstat.st_size, &prstat.st_blksize,
  222. &prstat.st_blocks,
  223. &prstat.st_atim_sec, &prstat.st_atim_nsec,
  224. &prstat.st_mtim_sec, &prstat.st_mtim_nsec,
  225. &prstat.st_ctim_sec, &prstat.st_ctim_nsec);
  226. assert(retval == 8 * 3 + 4 * 3 + 8 * 10);
  227. prstat_to_stat(response, &prstat);
  228. break;
  229. }
  230. case T_STATFS: {
  231. ProxyStatFS prstfs;
  232. retval = proxy_unmarshal(reply, PROXY_HDR_SZ,
  233. "qqqqqqqqqqq", &prstfs.f_type,
  234. &prstfs.f_bsize, &prstfs.f_blocks,
  235. &prstfs.f_bfree, &prstfs.f_bavail,
  236. &prstfs.f_files, &prstfs.f_ffree,
  237. &prstfs.f_fsid[0], &prstfs.f_fsid[1],
  238. &prstfs.f_namelen, &prstfs.f_frsize);
  239. assert(retval == 8 * 11);
  240. prstatfs_to_statfs(response, &prstfs);
  241. break;
  242. }
  243. case T_READLINK: {
  244. V9fsString target;
  245. v9fs_string_init(&target);
  246. retval = proxy_unmarshal(reply, PROXY_HDR_SZ, "s", &target);
  247. strcpy(response, target.data);
  248. v9fs_string_free(&target);
  249. break;
  250. }
  251. case T_LGETXATTR:
  252. case T_LLISTXATTR: {
  253. V9fsString xattr;
  254. v9fs_string_init(&xattr);
  255. retval = proxy_unmarshal(reply, PROXY_HDR_SZ, "s", &xattr);
  256. memcpy(response, xattr.data, xattr.size);
  257. v9fs_string_free(&xattr);
  258. break;
  259. }
  260. case T_GETVERSION:
  261. retval = proxy_unmarshal(reply, PROXY_HDR_SZ, "q", response);
  262. assert(retval == 8);
  263. break;
  264. default:
  265. return -1;
  266. }
  267. if (retval < 0) {
  268. *status = retval;
  269. }
  270. return 0;
  271. }
  272. /*
  273. * return < 0 on transport error.
  274. * *status is valid only if return >= 0
  275. */
  276. static int v9fs_receive_status(V9fsProxy *proxy,
  277. struct iovec *reply, int *status)
  278. {
  279. int retval;
  280. ProxyHeader header;
  281. *status = 0;
  282. reply->iov_len = 0;
  283. retval = socket_read(proxy->sockfd, reply->iov_base, PROXY_HDR_SZ);
  284. if (retval < 0) {
  285. return retval;
  286. }
  287. reply->iov_len = PROXY_HDR_SZ;
  288. retval = proxy_unmarshal(reply, 0, "dd", &header.type, &header.size);
  289. assert(retval == 4 * 2);
  290. retval = socket_read(proxy->sockfd,
  291. reply->iov_base + PROXY_HDR_SZ, header.size);
  292. if (retval < 0) {
  293. return retval;
  294. }
  295. reply->iov_len += header.size;
  296. retval = proxy_unmarshal(reply, PROXY_HDR_SZ, "d", status);
  297. assert(retval == 4);
  298. return 0;
  299. }
  300. /*
  301. * Proxy->header and proxy->request written to socket by QEMU process.
  302. * This request read by proxy helper process
  303. * returns 0 on success and -errno on error
  304. */
  305. static int v9fs_request(V9fsProxy *proxy, int type, void *response, ...)
  306. {
  307. dev_t rdev;
  308. va_list ap;
  309. int size = 0;
  310. int retval = 0;
  311. uint64_t offset;
  312. ProxyHeader header = { 0, 0};
  313. struct timespec spec[2];
  314. int flags, mode, uid, gid;
  315. V9fsString *name, *value;
  316. V9fsString *path, *oldpath;
  317. struct iovec *iovec = NULL, *reply = NULL;
  318. qemu_mutex_lock(&proxy->mutex);
  319. if (proxy->sockfd == -1) {
  320. retval = -EIO;
  321. goto err_out;
  322. }
  323. iovec = &proxy->out_iovec;
  324. reply = &proxy->in_iovec;
  325. va_start(ap, response);
  326. switch (type) {
  327. case T_OPEN:
  328. path = va_arg(ap, V9fsString *);
  329. flags = va_arg(ap, int);
  330. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, flags);
  331. if (retval > 0) {
  332. header.size = retval;
  333. header.type = T_OPEN;
  334. }
  335. break;
  336. case T_CREATE:
  337. path = va_arg(ap, V9fsString *);
  338. flags = va_arg(ap, int);
  339. mode = va_arg(ap, int);
  340. uid = va_arg(ap, int);
  341. gid = va_arg(ap, int);
  342. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sdddd", path,
  343. flags, mode, uid, gid);
  344. if (retval > 0) {
  345. header.size = retval;
  346. header.type = T_CREATE;
  347. }
  348. break;
  349. case T_MKNOD:
  350. path = va_arg(ap, V9fsString *);
  351. mode = va_arg(ap, int);
  352. rdev = va_arg(ap, long int);
  353. uid = va_arg(ap, int);
  354. gid = va_arg(ap, int);
  355. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddsdq",
  356. uid, gid, path, mode, rdev);
  357. if (retval > 0) {
  358. header.size = retval;
  359. header.type = T_MKNOD;
  360. }
  361. break;
  362. case T_MKDIR:
  363. path = va_arg(ap, V9fsString *);
  364. mode = va_arg(ap, int);
  365. uid = va_arg(ap, int);
  366. gid = va_arg(ap, int);
  367. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddsd",
  368. uid, gid, path, mode);
  369. if (retval > 0) {
  370. header.size = retval;
  371. header.type = T_MKDIR;
  372. }
  373. break;
  374. case T_SYMLINK:
  375. oldpath = va_arg(ap, V9fsString *);
  376. path = va_arg(ap, V9fsString *);
  377. uid = va_arg(ap, int);
  378. gid = va_arg(ap, int);
  379. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ddss",
  380. uid, gid, oldpath, path);
  381. if (retval > 0) {
  382. header.size = retval;
  383. header.type = T_SYMLINK;
  384. }
  385. break;
  386. case T_LINK:
  387. oldpath = va_arg(ap, V9fsString *);
  388. path = va_arg(ap, V9fsString *);
  389. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ss",
  390. oldpath, path);
  391. if (retval > 0) {
  392. header.size = retval;
  393. header.type = T_LINK;
  394. }
  395. break;
  396. case T_LSTAT:
  397. path = va_arg(ap, V9fsString *);
  398. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path);
  399. if (retval > 0) {
  400. header.size = retval;
  401. header.type = T_LSTAT;
  402. }
  403. break;
  404. case T_READLINK:
  405. path = va_arg(ap, V9fsString *);
  406. size = va_arg(ap, int);
  407. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, size);
  408. if (retval > 0) {
  409. header.size = retval;
  410. header.type = T_READLINK;
  411. }
  412. break;
  413. case T_STATFS:
  414. path = va_arg(ap, V9fsString *);
  415. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path);
  416. if (retval > 0) {
  417. header.size = retval;
  418. header.type = T_STATFS;
  419. }
  420. break;
  421. case T_CHMOD:
  422. path = va_arg(ap, V9fsString *);
  423. mode = va_arg(ap, int);
  424. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sd", path, mode);
  425. if (retval > 0) {
  426. header.size = retval;
  427. header.type = T_CHMOD;
  428. }
  429. break;
  430. case T_CHOWN:
  431. path = va_arg(ap, V9fsString *);
  432. uid = va_arg(ap, int);
  433. gid = va_arg(ap, int);
  434. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sdd", path, uid, gid);
  435. if (retval > 0) {
  436. header.size = retval;
  437. header.type = T_CHOWN;
  438. }
  439. break;
  440. case T_TRUNCATE:
  441. path = va_arg(ap, V9fsString *);
  442. offset = va_arg(ap, uint64_t);
  443. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sq", path, offset);
  444. if (retval > 0) {
  445. header.size = retval;
  446. header.type = T_TRUNCATE;
  447. }
  448. break;
  449. case T_UTIME:
  450. path = va_arg(ap, V9fsString *);
  451. spec[0].tv_sec = va_arg(ap, long);
  452. spec[0].tv_nsec = va_arg(ap, long);
  453. spec[1].tv_sec = va_arg(ap, long);
  454. spec[1].tv_nsec = va_arg(ap, long);
  455. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sqqqq", path,
  456. spec[0].tv_sec, spec[1].tv_nsec,
  457. spec[1].tv_sec, spec[1].tv_nsec);
  458. if (retval > 0) {
  459. header.size = retval;
  460. header.type = T_UTIME;
  461. }
  462. break;
  463. case T_RENAME:
  464. oldpath = va_arg(ap, V9fsString *);
  465. path = va_arg(ap, V9fsString *);
  466. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ss", oldpath, path);
  467. if (retval > 0) {
  468. header.size = retval;
  469. header.type = T_RENAME;
  470. }
  471. break;
  472. case T_REMOVE:
  473. path = va_arg(ap, V9fsString *);
  474. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path);
  475. if (retval > 0) {
  476. header.size = retval;
  477. header.type = T_REMOVE;
  478. }
  479. break;
  480. case T_LGETXATTR:
  481. size = va_arg(ap, int);
  482. path = va_arg(ap, V9fsString *);
  483. name = va_arg(ap, V9fsString *);
  484. retval = proxy_marshal(iovec, PROXY_HDR_SZ,
  485. "dss", size, path, name);
  486. if (retval > 0) {
  487. header.size = retval;
  488. header.type = T_LGETXATTR;
  489. }
  490. break;
  491. case T_LLISTXATTR:
  492. size = va_arg(ap, int);
  493. path = va_arg(ap, V9fsString *);
  494. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ds", size, path);
  495. if (retval > 0) {
  496. header.size = retval;
  497. header.type = T_LLISTXATTR;
  498. }
  499. break;
  500. case T_LSETXATTR:
  501. path = va_arg(ap, V9fsString *);
  502. name = va_arg(ap, V9fsString *);
  503. value = va_arg(ap, V9fsString *);
  504. size = va_arg(ap, int);
  505. flags = va_arg(ap, int);
  506. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "sssdd",
  507. path, name, value, size, flags);
  508. if (retval > 0) {
  509. header.size = retval;
  510. header.type = T_LSETXATTR;
  511. }
  512. break;
  513. case T_LREMOVEXATTR:
  514. path = va_arg(ap, V9fsString *);
  515. name = va_arg(ap, V9fsString *);
  516. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "ss", path, name);
  517. if (retval > 0) {
  518. header.size = retval;
  519. header.type = T_LREMOVEXATTR;
  520. }
  521. break;
  522. case T_GETVERSION:
  523. path = va_arg(ap, V9fsString *);
  524. retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path);
  525. if (retval > 0) {
  526. header.size = retval;
  527. header.type = T_GETVERSION;
  528. }
  529. break;
  530. default:
  531. error_report("Invalid type %d", type);
  532. retval = -EINVAL;
  533. break;
  534. }
  535. va_end(ap);
  536. if (retval < 0) {
  537. goto err_out;
  538. }
  539. /* marshal the header details */
  540. retval = proxy_marshal(iovec, 0, "dd", header.type, header.size);
  541. assert(retval == 4 * 2);
  542. header.size += PROXY_HDR_SZ;
  543. retval = qemu_write_full(proxy->sockfd, iovec->iov_base, header.size);
  544. if (retval != header.size) {
  545. goto close_error;
  546. }
  547. switch (type) {
  548. case T_OPEN:
  549. case T_CREATE:
  550. /*
  551. * A file descriptor is returned as response for
  552. * T_OPEN,T_CREATE on success
  553. */
  554. if (v9fs_receivefd(proxy->sockfd, &retval) < 0) {
  555. goto close_error;
  556. }
  557. break;
  558. case T_MKNOD:
  559. case T_MKDIR:
  560. case T_SYMLINK:
  561. case T_LINK:
  562. case T_CHMOD:
  563. case T_CHOWN:
  564. case T_RENAME:
  565. case T_TRUNCATE:
  566. case T_UTIME:
  567. case T_REMOVE:
  568. case T_LSETXATTR:
  569. case T_LREMOVEXATTR:
  570. if (v9fs_receive_status(proxy, reply, &retval) < 0) {
  571. goto close_error;
  572. }
  573. break;
  574. case T_LSTAT:
  575. case T_READLINK:
  576. case T_STATFS:
  577. case T_GETVERSION:
  578. if (v9fs_receive_response(proxy, type, &retval, response) < 0) {
  579. goto close_error;
  580. }
  581. break;
  582. case T_LGETXATTR:
  583. case T_LLISTXATTR:
  584. if (!size) {
  585. if (v9fs_receive_status(proxy, reply, &retval) < 0) {
  586. goto close_error;
  587. }
  588. } else {
  589. if (v9fs_receive_response(proxy, type, &retval, response) < 0) {
  590. goto close_error;
  591. }
  592. }
  593. break;
  594. }
  595. err_out:
  596. qemu_mutex_unlock(&proxy->mutex);
  597. return retval;
  598. close_error:
  599. close(proxy->sockfd);
  600. proxy->sockfd = -1;
  601. qemu_mutex_unlock(&proxy->mutex);
  602. return -EIO;
  603. }
  604. static int proxy_lstat(FsContext *fs_ctx, V9fsPath *fs_path, struct stat *stbuf)
  605. {
  606. int retval;
  607. retval = v9fs_request(fs_ctx->private, T_LSTAT, stbuf, fs_path);
  608. if (retval < 0) {
  609. errno = -retval;
  610. return -1;
  611. }
  612. return retval;
  613. }
  614. static ssize_t proxy_readlink(FsContext *fs_ctx, V9fsPath *fs_path,
  615. char *buf, size_t bufsz)
  616. {
  617. int retval;
  618. retval = v9fs_request(fs_ctx->private, T_READLINK, buf, fs_path, bufsz);
  619. if (retval < 0) {
  620. errno = -retval;
  621. return -1;
  622. }
  623. return strlen(buf);
  624. }
  625. static int proxy_close(FsContext *ctx, V9fsFidOpenState *fs)
  626. {
  627. return close(fs->fd);
  628. }
  629. static int proxy_closedir(FsContext *ctx, V9fsFidOpenState *fs)
  630. {
  631. return closedir(fs->dir.stream);
  632. }
  633. static int proxy_open(FsContext *ctx, V9fsPath *fs_path,
  634. int flags, V9fsFidOpenState *fs)
  635. {
  636. fs->fd = v9fs_request(ctx->private, T_OPEN, NULL, fs_path, flags);
  637. if (fs->fd < 0) {
  638. errno = -fs->fd;
  639. fs->fd = -1;
  640. }
  641. return fs->fd;
  642. }
  643. static int proxy_opendir(FsContext *ctx,
  644. V9fsPath *fs_path, V9fsFidOpenState *fs)
  645. {
  646. int serrno, fd;
  647. fs->dir.stream = NULL;
  648. fd = v9fs_request(ctx->private, T_OPEN, NULL, fs_path, O_DIRECTORY);
  649. if (fd < 0) {
  650. errno = -fd;
  651. return -1;
  652. }
  653. fs->dir.stream = fdopendir(fd);
  654. if (!fs->dir.stream) {
  655. serrno = errno;
  656. close(fd);
  657. errno = serrno;
  658. return -1;
  659. }
  660. return 0;
  661. }
  662. static void proxy_rewinddir(FsContext *ctx, V9fsFidOpenState *fs)
  663. {
  664. rewinddir(fs->dir.stream);
  665. }
  666. static off_t proxy_telldir(FsContext *ctx, V9fsFidOpenState *fs)
  667. {
  668. return telldir(fs->dir.stream);
  669. }
  670. static struct dirent *proxy_readdir(FsContext *ctx, V9fsFidOpenState *fs)
  671. {
  672. struct dirent *entry;
  673. entry = readdir(fs->dir.stream);
  674. #ifdef CONFIG_DARWIN
  675. if (!entry) {
  676. return NULL;
  677. }
  678. int td;
  679. td = telldir(fs->dir.stream);
  680. /* If telldir fails, fail the entire readdir call */
  681. if (td < 0) {
  682. return NULL;
  683. }
  684. entry->d_seekoff = td;
  685. #endif
  686. return entry;
  687. }
  688. static void proxy_seekdir(FsContext *ctx, V9fsFidOpenState *fs, off_t off)
  689. {
  690. seekdir(fs->dir.stream, off);
  691. }
  692. static ssize_t proxy_preadv(FsContext *ctx, V9fsFidOpenState *fs,
  693. const struct iovec *iov,
  694. int iovcnt, off_t offset)
  695. {
  696. ssize_t ret;
  697. #ifdef CONFIG_PREADV
  698. ret = preadv(fs->fd, iov, iovcnt, offset);
  699. #else
  700. ret = lseek(fs->fd, offset, SEEK_SET);
  701. if (ret >= 0) {
  702. ret = readv(fs->fd, iov, iovcnt);
  703. }
  704. #endif
  705. return ret;
  706. }
  707. static ssize_t proxy_pwritev(FsContext *ctx, V9fsFidOpenState *fs,
  708. const struct iovec *iov,
  709. int iovcnt, off_t offset)
  710. {
  711. ssize_t ret;
  712. #ifdef CONFIG_PREADV
  713. ret = pwritev(fs->fd, iov, iovcnt, offset);
  714. #else
  715. ret = lseek(fs->fd, offset, SEEK_SET);
  716. if (ret >= 0) {
  717. ret = writev(fs->fd, iov, iovcnt);
  718. }
  719. #endif
  720. #ifdef CONFIG_SYNC_FILE_RANGE
  721. if (ret > 0 && ctx->export_flags & V9FS_IMMEDIATE_WRITEOUT) {
  722. /*
  723. * Initiate a writeback. This is not a data integrity sync.
  724. * We want to ensure that we don't leave dirty pages in the cache
  725. * after write when writeout=immediate is sepcified.
  726. */
  727. sync_file_range(fs->fd, offset, ret,
  728. SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE);
  729. }
  730. #endif
  731. return ret;
  732. }
  733. static int proxy_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
  734. {
  735. int retval;
  736. retval = v9fs_request(fs_ctx->private, T_CHMOD, NULL, fs_path,
  737. credp->fc_mode);
  738. if (retval < 0) {
  739. errno = -retval;
  740. }
  741. return retval;
  742. }
  743. static int proxy_mknod(FsContext *fs_ctx, V9fsPath *dir_path,
  744. const char *name, FsCred *credp)
  745. {
  746. int retval;
  747. V9fsString fullname;
  748. v9fs_string_init(&fullname);
  749. v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
  750. retval = v9fs_request(fs_ctx->private, T_MKNOD, NULL, &fullname,
  751. credp->fc_mode, credp->fc_rdev,
  752. credp->fc_uid, credp->fc_gid);
  753. v9fs_string_free(&fullname);
  754. if (retval < 0) {
  755. errno = -retval;
  756. retval = -1;
  757. }
  758. return retval;
  759. }
  760. static int proxy_mkdir(FsContext *fs_ctx, V9fsPath *dir_path,
  761. const char *name, FsCred *credp)
  762. {
  763. int retval;
  764. V9fsString fullname;
  765. v9fs_string_init(&fullname);
  766. v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
  767. retval = v9fs_request(fs_ctx->private, T_MKDIR, NULL, &fullname,
  768. credp->fc_mode, credp->fc_uid, credp->fc_gid);
  769. v9fs_string_free(&fullname);
  770. if (retval < 0) {
  771. errno = -retval;
  772. retval = -1;
  773. }
  774. return retval;
  775. }
  776. static int proxy_fstat(FsContext *fs_ctx, int fid_type,
  777. V9fsFidOpenState *fs, struct stat *stbuf)
  778. {
  779. int fd;
  780. if (fid_type == P9_FID_DIR) {
  781. fd = dirfd(fs->dir.stream);
  782. } else {
  783. fd = fs->fd;
  784. }
  785. return fstat(fd, stbuf);
  786. }
  787. static int proxy_open2(FsContext *fs_ctx, V9fsPath *dir_path, const char *name,
  788. int flags, FsCred *credp, V9fsFidOpenState *fs)
  789. {
  790. V9fsString fullname;
  791. v9fs_string_init(&fullname);
  792. v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
  793. fs->fd = v9fs_request(fs_ctx->private, T_CREATE, NULL, &fullname, flags,
  794. credp->fc_mode, credp->fc_uid, credp->fc_gid);
  795. v9fs_string_free(&fullname);
  796. if (fs->fd < 0) {
  797. errno = -fs->fd;
  798. fs->fd = -1;
  799. }
  800. return fs->fd;
  801. }
  802. static int proxy_symlink(FsContext *fs_ctx, const char *oldpath,
  803. V9fsPath *dir_path, const char *name, FsCred *credp)
  804. {
  805. int retval;
  806. V9fsString fullname, target;
  807. v9fs_string_init(&fullname);
  808. v9fs_string_init(&target);
  809. v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
  810. v9fs_string_sprintf(&target, "%s", oldpath);
  811. retval = v9fs_request(fs_ctx->private, T_SYMLINK, NULL, &target, &fullname,
  812. credp->fc_uid, credp->fc_gid);
  813. v9fs_string_free(&fullname);
  814. v9fs_string_free(&target);
  815. if (retval < 0) {
  816. errno = -retval;
  817. retval = -1;
  818. }
  819. return retval;
  820. }
  821. static int proxy_link(FsContext *ctx, V9fsPath *oldpath,
  822. V9fsPath *dirpath, const char *name)
  823. {
  824. int retval;
  825. V9fsString newpath;
  826. v9fs_string_init(&newpath);
  827. v9fs_string_sprintf(&newpath, "%s/%s", dirpath->data, name);
  828. retval = v9fs_request(ctx->private, T_LINK, NULL, oldpath, &newpath);
  829. v9fs_string_free(&newpath);
  830. if (retval < 0) {
  831. errno = -retval;
  832. retval = -1;
  833. }
  834. return retval;
  835. }
  836. static int proxy_truncate(FsContext *ctx, V9fsPath *fs_path, off_t size)
  837. {
  838. int retval;
  839. retval = v9fs_request(ctx->private, T_TRUNCATE, NULL, fs_path, size);
  840. if (retval < 0) {
  841. errno = -retval;
  842. return -1;
  843. }
  844. return 0;
  845. }
  846. static int proxy_rename(FsContext *ctx, const char *oldpath,
  847. const char *newpath)
  848. {
  849. int retval;
  850. V9fsString oldname, newname;
  851. v9fs_string_init(&oldname);
  852. v9fs_string_init(&newname);
  853. v9fs_string_sprintf(&oldname, "%s", oldpath);
  854. v9fs_string_sprintf(&newname, "%s", newpath);
  855. retval = v9fs_request(ctx->private, T_RENAME, NULL, &oldname, &newname);
  856. v9fs_string_free(&oldname);
  857. v9fs_string_free(&newname);
  858. if (retval < 0) {
  859. errno = -retval;
  860. }
  861. return retval;
  862. }
  863. static int proxy_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
  864. {
  865. int retval;
  866. retval = v9fs_request(fs_ctx->private, T_CHOWN, NULL, fs_path,
  867. credp->fc_uid, credp->fc_gid);
  868. if (retval < 0) {
  869. errno = -retval;
  870. }
  871. return retval;
  872. }
  873. static int proxy_utimensat(FsContext *s, V9fsPath *fs_path,
  874. const struct timespec *buf)
  875. {
  876. int retval;
  877. retval = v9fs_request(s->private, T_UTIME, NULL, fs_path,
  878. buf[0].tv_sec, buf[0].tv_nsec,
  879. buf[1].tv_sec, buf[1].tv_nsec);
  880. if (retval < 0) {
  881. errno = -retval;
  882. }
  883. return retval;
  884. }
  885. static int proxy_remove(FsContext *ctx, const char *path)
  886. {
  887. int retval;
  888. V9fsString name;
  889. v9fs_string_init(&name);
  890. v9fs_string_sprintf(&name, "%s", path);
  891. retval = v9fs_request(ctx->private, T_REMOVE, NULL, &name);
  892. v9fs_string_free(&name);
  893. if (retval < 0) {
  894. errno = -retval;
  895. }
  896. return retval;
  897. }
  898. static int proxy_fsync(FsContext *ctx, int fid_type,
  899. V9fsFidOpenState *fs, int datasync)
  900. {
  901. int fd;
  902. if (fid_type == P9_FID_DIR) {
  903. fd = dirfd(fs->dir.stream);
  904. } else {
  905. fd = fs->fd;
  906. }
  907. if (datasync) {
  908. return qemu_fdatasync(fd);
  909. } else {
  910. return fsync(fd);
  911. }
  912. }
  913. static int proxy_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf)
  914. {
  915. int retval;
  916. retval = v9fs_request(s->private, T_STATFS, stbuf, fs_path);
  917. if (retval < 0) {
  918. errno = -retval;
  919. return -1;
  920. }
  921. return retval;
  922. }
  923. static ssize_t proxy_lgetxattr(FsContext *ctx, V9fsPath *fs_path,
  924. const char *name, void *value, size_t size)
  925. {
  926. int retval;
  927. V9fsString xname;
  928. v9fs_string_init(&xname);
  929. v9fs_string_sprintf(&xname, "%s", name);
  930. retval = v9fs_request(ctx->private, T_LGETXATTR, value, size, fs_path,
  931. &xname);
  932. v9fs_string_free(&xname);
  933. if (retval < 0) {
  934. errno = -retval;
  935. }
  936. return retval;
  937. }
  938. static ssize_t proxy_llistxattr(FsContext *ctx, V9fsPath *fs_path,
  939. void *value, size_t size)
  940. {
  941. int retval;
  942. retval = v9fs_request(ctx->private, T_LLISTXATTR, value, size, fs_path);
  943. if (retval < 0) {
  944. errno = -retval;
  945. }
  946. return retval;
  947. }
  948. static int proxy_lsetxattr(FsContext *ctx, V9fsPath *fs_path, const char *name,
  949. void *value, size_t size, int flags)
  950. {
  951. int retval;
  952. V9fsString xname, xvalue;
  953. v9fs_string_init(&xname);
  954. v9fs_string_sprintf(&xname, "%s", name);
  955. v9fs_string_init(&xvalue);
  956. xvalue.size = size;
  957. xvalue.data = g_malloc(size);
  958. memcpy(xvalue.data, value, size);
  959. retval = v9fs_request(ctx->private, T_LSETXATTR, value, fs_path, &xname,
  960. &xvalue, size, flags);
  961. v9fs_string_free(&xname);
  962. v9fs_string_free(&xvalue);
  963. if (retval < 0) {
  964. errno = -retval;
  965. }
  966. return retval;
  967. }
  968. static int proxy_lremovexattr(FsContext *ctx, V9fsPath *fs_path,
  969. const char *name)
  970. {
  971. int retval;
  972. V9fsString xname;
  973. v9fs_string_init(&xname);
  974. v9fs_string_sprintf(&xname, "%s", name);
  975. retval = v9fs_request(ctx->private, T_LREMOVEXATTR, NULL, fs_path, &xname);
  976. v9fs_string_free(&xname);
  977. if (retval < 0) {
  978. errno = -retval;
  979. }
  980. return retval;
  981. }
  982. static int proxy_name_to_path(FsContext *ctx, V9fsPath *dir_path,
  983. const char *name, V9fsPath *target)
  984. {
  985. if (dir_path) {
  986. v9fs_path_sprintf(target, "%s/%s", dir_path->data, name);
  987. } else {
  988. v9fs_path_sprintf(target, "%s", name);
  989. }
  990. return 0;
  991. }
  992. static int proxy_renameat(FsContext *ctx, V9fsPath *olddir,
  993. const char *old_name, V9fsPath *newdir,
  994. const char *new_name)
  995. {
  996. int ret;
  997. V9fsString old_full_name, new_full_name;
  998. v9fs_string_init(&old_full_name);
  999. v9fs_string_init(&new_full_name);
  1000. v9fs_string_sprintf(&old_full_name, "%s/%s", olddir->data, old_name);
  1001. v9fs_string_sprintf(&new_full_name, "%s/%s", newdir->data, new_name);
  1002. ret = proxy_rename(ctx, old_full_name.data, new_full_name.data);
  1003. v9fs_string_free(&old_full_name);
  1004. v9fs_string_free(&new_full_name);
  1005. return ret;
  1006. }
  1007. static int proxy_unlinkat(FsContext *ctx, V9fsPath *dir,
  1008. const char *name, int flags)
  1009. {
  1010. int ret;
  1011. V9fsString fullname;
  1012. v9fs_string_init(&fullname);
  1013. v9fs_string_sprintf(&fullname, "%s/%s", dir->data, name);
  1014. ret = proxy_remove(ctx, fullname.data);
  1015. v9fs_string_free(&fullname);
  1016. return ret;
  1017. }
  1018. static int proxy_ioc_getversion(FsContext *fs_ctx, V9fsPath *path,
  1019. mode_t st_mode, uint64_t *st_gen)
  1020. {
  1021. int err;
  1022. /* Do not try to open special files like device nodes, fifos etc
  1023. * we can get fd for regular files and directories only
  1024. */
  1025. if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) {
  1026. errno = ENOTTY;
  1027. return -1;
  1028. }
  1029. err = v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, path);
  1030. if (err < 0) {
  1031. errno = -err;
  1032. err = -1;
  1033. }
  1034. return err;
  1035. }
  1036. static int connect_namedsocket(const char *path, Error **errp)
  1037. {
  1038. int sockfd;
  1039. struct sockaddr_un helper;
  1040. if (strlen(path) >= sizeof(helper.sun_path)) {
  1041. error_setg(errp, "socket name too long");
  1042. return -1;
  1043. }
  1044. sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
  1045. if (sockfd < 0) {
  1046. error_setg_errno(errp, errno, "failed to create client socket");
  1047. return -1;
  1048. }
  1049. strcpy(helper.sun_path, path);
  1050. helper.sun_family = AF_UNIX;
  1051. if (connect(sockfd, (struct sockaddr *)&helper, sizeof(helper)) < 0) {
  1052. error_setg_errno(errp, errno, "failed to connect to '%s'", path);
  1053. close(sockfd);
  1054. return -1;
  1055. }
  1056. /* remove the socket for security reasons */
  1057. unlink(path);
  1058. return sockfd;
  1059. }
  1060. static void error_append_socket_sockfd_hint(Error *const *errp)
  1061. {
  1062. error_append_hint(errp, "Either specify socket=/some/path where /some/path"
  1063. " points to a listening AF_UNIX socket or sock_fd=fd"
  1064. " where fd is a file descriptor to a connected AF_UNIX"
  1065. " socket\n");
  1066. }
  1067. static int proxy_parse_opts(QemuOpts *opts, FsDriverEntry *fs, Error **errp)
  1068. {
  1069. const char *socket = qemu_opt_get(opts, "socket");
  1070. const char *sock_fd = qemu_opt_get(opts, "sock_fd");
  1071. if (!socket && !sock_fd) {
  1072. error_setg(errp, "both socket and sock_fd properties are missing");
  1073. error_append_socket_sockfd_hint(errp);
  1074. return -1;
  1075. }
  1076. if (socket && sock_fd) {
  1077. error_setg(errp, "both socket and sock_fd properties are set");
  1078. error_append_socket_sockfd_hint(errp);
  1079. return -1;
  1080. }
  1081. if (socket) {
  1082. fs->path = g_strdup(socket);
  1083. fs->export_flags |= V9FS_PROXY_SOCK_NAME;
  1084. } else {
  1085. fs->path = g_strdup(sock_fd);
  1086. fs->export_flags |= V9FS_PROXY_SOCK_FD;
  1087. }
  1088. return 0;
  1089. }
  1090. static int proxy_init(FsContext *ctx, Error **errp)
  1091. {
  1092. V9fsProxy *proxy = g_new(V9fsProxy, 1);
  1093. int sock_id;
  1094. if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) {
  1095. sock_id = connect_namedsocket(ctx->fs_root, errp);
  1096. } else {
  1097. sock_id = atoi(ctx->fs_root);
  1098. if (sock_id < 0) {
  1099. error_setg(errp, "socket descriptor not initialized");
  1100. }
  1101. }
  1102. if (sock_id < 0) {
  1103. g_free(proxy);
  1104. return -1;
  1105. }
  1106. g_free(ctx->fs_root);
  1107. ctx->fs_root = NULL;
  1108. proxy->in_iovec.iov_base = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ);
  1109. proxy->in_iovec.iov_len = PROXY_MAX_IO_SZ + PROXY_HDR_SZ;
  1110. proxy->out_iovec.iov_base = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ);
  1111. proxy->out_iovec.iov_len = PROXY_MAX_IO_SZ + PROXY_HDR_SZ;
  1112. ctx->private = proxy;
  1113. proxy->sockfd = sock_id;
  1114. qemu_mutex_init(&proxy->mutex);
  1115. ctx->export_flags |= V9FS_PATHNAME_FSCONTEXT;
  1116. ctx->exops.get_st_gen = proxy_ioc_getversion;
  1117. return 0;
  1118. }
  1119. static void proxy_cleanup(FsContext *ctx)
  1120. {
  1121. V9fsProxy *proxy = ctx->private;
  1122. if (!proxy) {
  1123. return;
  1124. }
  1125. g_free(proxy->out_iovec.iov_base);
  1126. g_free(proxy->in_iovec.iov_base);
  1127. if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) {
  1128. close(proxy->sockfd);
  1129. }
  1130. g_free(proxy);
  1131. }
  1132. FileOperations proxy_ops = {
  1133. .parse_opts = proxy_parse_opts,
  1134. .init = proxy_init,
  1135. .cleanup = proxy_cleanup,
  1136. .lstat = proxy_lstat,
  1137. .readlink = proxy_readlink,
  1138. .close = proxy_close,
  1139. .closedir = proxy_closedir,
  1140. .open = proxy_open,
  1141. .opendir = proxy_opendir,
  1142. .rewinddir = proxy_rewinddir,
  1143. .telldir = proxy_telldir,
  1144. .readdir = proxy_readdir,
  1145. .seekdir = proxy_seekdir,
  1146. .preadv = proxy_preadv,
  1147. .pwritev = proxy_pwritev,
  1148. .chmod = proxy_chmod,
  1149. .mknod = proxy_mknod,
  1150. .mkdir = proxy_mkdir,
  1151. .fstat = proxy_fstat,
  1152. .open2 = proxy_open2,
  1153. .symlink = proxy_symlink,
  1154. .link = proxy_link,
  1155. .truncate = proxy_truncate,
  1156. .rename = proxy_rename,
  1157. .chown = proxy_chown,
  1158. .utimensat = proxy_utimensat,
  1159. .remove = proxy_remove,
  1160. .fsync = proxy_fsync,
  1161. .statfs = proxy_statfs,
  1162. .lgetxattr = proxy_lgetxattr,
  1163. .llistxattr = proxy_llistxattr,
  1164. .lsetxattr = proxy_lsetxattr,
  1165. .lremovexattr = proxy_lremovexattr,
  1166. .name_to_path = proxy_name_to_path,
  1167. .renameat = proxy_renameat,
  1168. .unlinkat = proxy_unlinkat,
  1169. };