2 * Helper for QEMU Proxy FS Driver
3 * Copyright IBM, Corp. 2011
6 * M. Mohan Kumar <mohan@in.ibm.com>
8 * This work is licensed under the terms of the GNU GPL, version 2. See
9 * the COPYING file in the top-level directory.
13 * NOTE: The 9p 'proxy' backend is deprecated (since QEMU 8.1) and will be
14 * removed in a future version of QEMU!
17 #include "qemu/osdep.h"
18 #include <glib/gstdio.h>
19 #include <sys/resource.h>
22 #include <sys/fsuid.h>
24 #include <sys/ioctl.h>
26 #ifdef CONFIG_LINUX_MAGIC_H
27 #include <linux/magic.h>
30 #include "qemu/sockets.h"
31 #include "qemu/xattr.h"
32 #include "9p-iov-marshal.h"
33 #include "hw/9pfs/9p-proxy.h"
34 #include "hw/9pfs/9p-util.h"
35 #include "fsdev/9p-iov-marshal.h"
37 #define PROGNAME "virtfs-proxy-helper"
39 #ifndef XFS_SUPER_MAGIC
40 #define XFS_SUPER_MAGIC 0x58465342
42 #ifndef EXT2_SUPER_MAGIC
43 #define EXT2_SUPER_MAGIC 0xEF53
45 #ifndef REISERFS_SUPER_MAGIC
46 #define REISERFS_SUPER_MAGIC 0x52654973
48 #ifndef BTRFS_SUPER_MAGIC
49 #define BTRFS_SUPER_MAGIC 0x9123683E
52 static const struct option helper_opts[] = {
53 {"fd", required_argument, NULL, 'f'},
54 {"path", required_argument, NULL, 'p'},
55 {"nodaemon", no_argument, NULL, 'n'},
56 {"socket", required_argument, NULL, 's'},
57 {"uid", required_argument, NULL, 'u'},
58 {"gid", required_argument, NULL, 'g'},
62 static bool is_daemon;
63 static bool get_version; /* IOC getversion IOCTL supported */
64 static char *prog_name;
66 static void G_GNUC_PRINTF(2, 3) do_log(int loglevel, const char *format, ...)
72 vsyslog(LOG_CRIT, format, ap);
74 vfprintf(stderr, format, ap);
79 static void do_perror(const char *string)
82 syslog(LOG_CRIT, "%s:%s", string, strerror(errno));
84 fprintf(stderr, "%s:%s\n", string, strerror(errno));
88 static int init_capabilities(void)
90 /* helper needs following capabilities only */
102 capng_clear(CAPNG_SELECT_BOTH);
103 for (i = 0; i < ARRAY_SIZE(cap_list); i++) {
104 if (capng_update(CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED,
106 do_perror("capng_update");
110 if (capng_apply(CAPNG_SELECT_BOTH) < 0) {
111 do_perror("capng_apply");
115 /* Prepare effective set for setugid. */
116 for (i = 0; i < ARRAY_SIZE(cap_list); i++) {
117 if (cap_list[i] == CAP_DAC_OVERRIDE) {
121 if (capng_update(CAPNG_DROP, CAPNG_EFFECTIVE,
123 do_perror("capng_update");
130 static int socket_read(int sockfd, void *buff, ssize_t size)
132 ssize_t retval, total = 0;
135 retval = read(sockfd, buff, size);
140 if (errno == EINTR) {
152 static int socket_write(int sockfd, void *buff, ssize_t size)
154 ssize_t retval, total = 0;
157 retval = write(sockfd, buff, size);
159 if (errno == EINTR) {
171 static int read_request(int sockfd, struct iovec *iovec, ProxyHeader *header)
176 * read the request header.
179 retval = socket_read(sockfd, iovec->iov_base, PROXY_HDR_SZ);
183 iovec->iov_len = PROXY_HDR_SZ;
184 retval = proxy_unmarshal(iovec, 0, "dd", &header->type, &header->size);
189 * We can't process message.size > PROXY_MAX_IO_SZ.
190 * Treat it as fatal error
192 if (header->size > PROXY_MAX_IO_SZ) {
195 retval = socket_read(sockfd, iovec->iov_base + PROXY_HDR_SZ, header->size);
199 iovec->iov_len += header->size;
203 static int send_fd(int sockfd, int fd)
208 struct cmsghdr *cmsg;
209 union MsgControl msg_control;
211 iov.iov_base = &data;
212 iov.iov_len = sizeof(data);
214 memset(&msg, 0, sizeof(msg));
217 /* No ancillary data on error */
219 /* fd is really negative errno if the request failed */
222 data = V9FS_FD_VALID;
223 msg.msg_control = &msg_control;
224 msg.msg_controllen = sizeof(msg_control);
226 cmsg = &msg_control.cmsg;
227 cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
228 cmsg->cmsg_level = SOL_SOCKET;
229 cmsg->cmsg_type = SCM_RIGHTS;
230 memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
234 retval = sendmsg(sockfd, &msg, 0);
235 } while (retval < 0 && errno == EINTR);
245 static int send_status(int sockfd, struct iovec *iovec, int status)
248 int retval, msg_size;
251 header.type = T_ERROR;
253 header.type = T_SUCCESS;
255 header.size = sizeof(status);
257 * marshal the return status. We don't check error.
258 * because we are sure we have enough space for the status
260 msg_size = proxy_marshal(iovec, 0, "ddd", header.type,
261 header.size, status);
265 retval = socket_write(sockfd, iovec->iov_base, msg_size);
273 * from man 7 capabilities, section
274 * Effect of User ID Changes on Capabilities:
275 * If the effective user ID is changed from nonzero to 0, then the permitted
276 * set is copied to the effective set. If the effective user ID is changed
277 * from 0 to nonzero, then all capabilities are are cleared from the effective
280 * The setfsuid/setfsgid man pages warn that changing the effective user ID may
281 * expose the program to unwanted signals, but this is not true anymore: for an
282 * unprivileged (without CAP_KILL) program to send a signal, the real or
283 * effective user ID of the sending process must equal the real or saved user
284 * ID of the target process. Even when dropping privileges, it is enough to
285 * keep the saved UID to a "privileged" value and virtfs-proxy-helper won't
286 * be exposed to signals. So just use setresuid/setresgid.
288 static int setugid(int uid, int gid, int *suid, int *sgid)
295 if (setresgid(-1, gid, *sgid) == -1) {
299 if (setresuid(-1, uid, *suid) == -1) {
304 if (uid == 0 && gid == 0) {
305 /* Linux has already copied the permitted set to the effective set. */
310 * All capabilities have been cleared from the effective set. However
311 * we still need DAC_OVERRIDE because we don't change supplementary
312 * group ids, and hence may be subject to DAC rules. init_capabilities
313 * left the set of capabilities that we want in libcap-ng's state.
315 if (capng_apply(CAPNG_SELECT_CAPS) < 0) {
317 do_perror("capng_apply");
323 if (setresuid(-1, *suid, *suid) == -1) {
327 if (setresgid(-1, *sgid, *sgid) == -1) {
334 * This is used to reset the ugid back with the saved values
335 * There is nothing much we can do checking error values here.
337 static void resetugid(int suid, int sgid)
339 if (setresgid(-1, sgid, sgid) == -1) {
342 if (setresuid(-1, suid, suid) == -1) {
348 * Open regular file or directory. Attempts to open any special file are
351 * returns file descriptor or -1 on error
353 static int open_regular(const char *pathname, int flags, mode_t mode)
357 fd = open(pathname, flags, mode);
362 if (close_if_special_file(fd) < 0) {
370 * send response in two parts
372 * 2) Response or error status
373 * This function should be called with marshaled response
374 * send_response constructs header part and error part only.
375 * send response sends {ProxyHeader,Response} if the request was success
376 * otherwise sends {ProxyHeader,error status}
378 static int send_response(int sock, struct iovec *iovec, int size)
384 * If response size exceeds available iovec->iov_len,
387 if (size > PROXY_MAX_IO_SZ) {
393 * In case of error we would not have got the error encoded
394 * already so encode the error here.
396 header.type = T_ERROR;
397 header.size = sizeof(size);
398 proxy_marshal(iovec, PROXY_HDR_SZ, "d", size);
400 header.type = T_SUCCESS;
403 proxy_marshal(iovec, 0, "dd", header.type, header.size);
404 retval = socket_write(sock, iovec->iov_base, header.size + PROXY_HDR_SZ);
412 * gets generation number
413 * returns -errno on failure and sizeof(generation number) on success
415 static int do_getversion(struct iovec *iovec, struct iovec *out_iovec)
418 int retval = -ENOTTY;
419 #ifdef FS_IOC_GETVERSION
425 /* no need to issue ioctl */
428 retval = proxy_marshal(out_iovec, PROXY_HDR_SZ, "q", version);
431 #ifdef FS_IOC_GETVERSION
432 retval = proxy_unmarshal(iovec, PROXY_HDR_SZ, "s", &path);
437 fd = open(path.data, O_RDONLY);
442 if (ioctl(fd, FS_IOC_GETVERSION, &version) < 0) {
445 retval = proxy_marshal(out_iovec, PROXY_HDR_SZ, "q", version);
449 v9fs_string_free(&path);
454 static int do_getxattr(int type, struct iovec *iovec, struct iovec *out_iovec)
456 int size = 0, offset, retval;
457 V9fsString path, name, xattr;
459 v9fs_string_init(&xattr);
460 v9fs_string_init(&path);
461 retval = proxy_unmarshal(iovec, PROXY_HDR_SZ, "ds", &size, &path);
465 offset = PROXY_HDR_SZ + retval;
468 xattr.data = g_malloc(size);
473 v9fs_string_init(&name);
474 retval = proxy_unmarshal(iovec, offset, "s", &name);
476 retval = lgetxattr(path.data, name.data, xattr.data, size);
483 v9fs_string_free(&name);
486 retval = llistxattr(path.data, xattr.data, size);
499 proxy_marshal(out_iovec, PROXY_HDR_SZ, "d", retval);
500 retval = sizeof(retval);
502 retval = proxy_marshal(out_iovec, PROXY_HDR_SZ, "s", &xattr);
505 v9fs_string_free(&xattr);
506 v9fs_string_free(&path);
510 static void stat_to_prstat(ProxyStat *pr_stat, struct stat *stat)
512 memset(pr_stat, 0, sizeof(*pr_stat));
513 pr_stat->st_dev = stat->st_dev;
514 pr_stat->st_ino = stat->st_ino;
515 pr_stat->st_nlink = stat->st_nlink;
516 pr_stat->st_mode = stat->st_mode;
517 pr_stat->st_uid = stat->st_uid;
518 pr_stat->st_gid = stat->st_gid;
519 pr_stat->st_rdev = stat->st_rdev;
520 pr_stat->st_size = stat->st_size;
521 pr_stat->st_blksize = stat->st_blksize;
522 pr_stat->st_blocks = stat->st_blocks;
523 pr_stat->st_atim_sec = stat->st_atim.tv_sec;
524 pr_stat->st_atim_nsec = stat->st_atim.tv_nsec;
525 pr_stat->st_mtim_sec = stat->st_mtim.tv_sec;
526 pr_stat->st_mtim_nsec = stat->st_mtim.tv_nsec;
527 pr_stat->st_ctim_sec = stat->st_ctim.tv_sec;
528 pr_stat->st_ctim_nsec = stat->st_ctim.tv_nsec;
531 static void statfs_to_prstatfs(ProxyStatFS *pr_stfs, struct statfs *stfs)
533 memset(pr_stfs, 0, sizeof(*pr_stfs));
534 pr_stfs->f_type = stfs->f_type;
535 pr_stfs->f_bsize = stfs->f_bsize;
536 pr_stfs->f_blocks = stfs->f_blocks;
537 pr_stfs->f_bfree = stfs->f_bfree;
538 pr_stfs->f_bavail = stfs->f_bavail;
539 pr_stfs->f_files = stfs->f_files;
540 pr_stfs->f_ffree = stfs->f_ffree;
541 pr_stfs->f_fsid[0] = stfs->f_fsid.__val[0];
542 pr_stfs->f_fsid[1] = stfs->f_fsid.__val[1];
543 pr_stfs->f_namelen = stfs->f_namelen;
544 pr_stfs->f_frsize = stfs->f_frsize;
548 * Gets stat/statfs information and packs in out_iovec structure
549 * on success returns number of bytes packed in out_iovec structure
550 * otherwise returns -errno
552 static int do_stat(int type, struct iovec *iovec, struct iovec *out_iovec)
559 struct statfs stfs_buf;
561 v9fs_string_init(&path);
562 retval = proxy_unmarshal(iovec, PROXY_HDR_SZ, "s", &path);
569 retval = lstat(path.data, &st_buf);
573 stat_to_prstat(&pr_stat, &st_buf);
574 retval = proxy_marshal(out_iovec, PROXY_HDR_SZ,
575 "qqqdddqqqqqqqqqq", pr_stat.st_dev,
576 pr_stat.st_ino, pr_stat.st_nlink,
577 pr_stat.st_mode, pr_stat.st_uid,
578 pr_stat.st_gid, pr_stat.st_rdev,
579 pr_stat.st_size, pr_stat.st_blksize,
581 pr_stat.st_atim_sec, pr_stat.st_atim_nsec,
582 pr_stat.st_mtim_sec, pr_stat.st_mtim_nsec,
583 pr_stat.st_ctim_sec, pr_stat.st_ctim_nsec);
587 retval = statfs(path.data, &stfs_buf);
591 statfs_to_prstatfs(&pr_stfs, &stfs_buf);
592 retval = proxy_marshal(out_iovec, PROXY_HDR_SZ,
593 "qqqqqqqqqqq", pr_stfs.f_type,
594 pr_stfs.f_bsize, pr_stfs.f_blocks,
595 pr_stfs.f_bfree, pr_stfs.f_bavail,
596 pr_stfs.f_files, pr_stfs.f_ffree,
597 pr_stfs.f_fsid[0], pr_stfs.f_fsid[1],
598 pr_stfs.f_namelen, pr_stfs.f_frsize);
602 v9fs_string_free(&path);
606 static int do_readlink(struct iovec *iovec, struct iovec *out_iovec)
610 V9fsString target, path;
612 v9fs_string_init(&path);
613 retval = proxy_unmarshal(iovec, PROXY_HDR_SZ, "sd", &path, &size);
615 v9fs_string_free(&path);
618 buffer = g_malloc(size);
619 v9fs_string_init(&target);
620 retval = readlink(path.data, buffer, size - 1);
622 buffer[retval] = '\0';
623 v9fs_string_sprintf(&target, "%s", buffer);
624 retval = proxy_marshal(out_iovec, PROXY_HDR_SZ, "s", &target);
629 v9fs_string_free(&target);
630 v9fs_string_free(&path);
635 * create other filesystem objects and send 0 on success
636 * return -errno on error
638 static int do_create_others(int type, struct iovec *iovec)
642 int offset = PROXY_HDR_SZ;
643 V9fsString oldpath, path;
644 int mode, uid, gid, cur_uid, cur_gid;
646 v9fs_string_init(&path);
647 v9fs_string_init(&oldpath);
649 retval = proxy_unmarshal(iovec, offset, "dd", &uid, &gid);
654 retval = setugid(uid, gid, &cur_uid, &cur_gid);
656 goto unmarshal_err_out;
660 retval = proxy_unmarshal(iovec, offset, "sdq", &path, &mode, &rdev);
664 retval = mknod(path.data, mode, rdev);
667 retval = proxy_unmarshal(iovec, offset, "sd", &path, &mode);
671 retval = g_mkdir(path.data, mode);
674 retval = proxy_unmarshal(iovec, offset, "ss", &oldpath, &path);
678 retval = symlink(oldpath.data, path.data);
686 resetugid(cur_uid, cur_gid);
688 v9fs_string_free(&path);
689 v9fs_string_free(&oldpath);
694 * create a file and send fd on success
695 * return -errno on error
697 static int do_create(struct iovec *iovec)
701 int flags, mode, uid, gid, cur_uid, cur_gid;
703 v9fs_string_init(&path);
704 ret = proxy_unmarshal(iovec, PROXY_HDR_SZ, "sdddd",
705 &path, &flags, &mode, &uid, &gid);
707 goto unmarshal_err_out;
709 ret = setugid(uid, gid, &cur_uid, &cur_gid);
711 goto unmarshal_err_out;
713 ret = open_regular(path.data, flags, mode);
718 resetugid(cur_uid, cur_gid);
720 v9fs_string_free(&path);
725 * open a file and send fd on success
726 * return -errno on error
728 static int do_open(struct iovec *iovec)
733 v9fs_string_init(&path);
734 ret = proxy_unmarshal(iovec, PROXY_HDR_SZ, "sd", &path, &flags);
738 ret = open_regular(path.data, flags, 0);
743 v9fs_string_free(&path);
747 /* create unix domain socket and return the descriptor */
748 static int proxy_socket(const char *path, uid_t uid, gid_t gid)
751 struct sockaddr_un proxy, qemu;
754 /* requested socket already exists, refuse to start */
755 if (!access(path, F_OK)) {
756 do_log(LOG_CRIT, "socket already exists\n");
760 if (strlen(path) >= sizeof(proxy.sun_path)) {
761 do_log(LOG_CRIT, "UNIX domain socket path exceeds %zu characters\n",
762 sizeof(proxy.sun_path));
766 sock = socket(AF_UNIX, SOCK_STREAM, 0);
772 /* mask other part of mode bits */
775 proxy.sun_family = AF_UNIX;
776 strcpy(proxy.sun_path, path);
777 if (bind(sock, (struct sockaddr *)&proxy,
778 sizeof(struct sockaddr_un)) < 0) {
782 if (chown(proxy.sun_path, uid, gid) < 0) {
786 if (listen(sock, 1) < 0) {
792 client = accept(sock, (struct sockaddr *)&qemu, &size);
805 static void usage(void)
807 fprintf(stderr, "usage: %s\n"
808 " -p|--path <path> 9p path to export\n"
809 " {-f|--fd <socket-descriptor>} socket file descriptor to be used\n"
810 " {-s|--socket <socketname> socket file used for communication\n"
811 " \t-u|--uid <uid> -g|--gid <gid>} - uid:gid combination to give "
812 " access to this socket\n"
813 " \tNote: -s & -f can not be used together\n"
814 " [-n|--nodaemon] Run as a normal program\n",
818 static int process_reply(int sock, int type,
819 struct iovec *out_iovec, int retval)
824 if (send_fd(sock, retval) < 0) {
840 if (send_status(sock, out_iovec, retval) < 0) {
850 if (send_response(sock, out_iovec, retval) < 0) {
861 static int process_requests(int sock)
869 V9fsString name, value;
870 struct timespec spec[2];
871 V9fsString oldpath, path;
872 struct iovec in_iovec, out_iovec;
874 in_iovec.iov_base = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ);
875 in_iovec.iov_len = PROXY_MAX_IO_SZ + PROXY_HDR_SZ;
876 out_iovec.iov_base = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ);
877 out_iovec.iov_len = PROXY_MAX_IO_SZ + PROXY_HDR_SZ;
881 * initialize the header type, so that we send
882 * response to proper request type.
885 retval = read_request(sock, &in_iovec, &header);
890 switch (header.type) {
892 retval = do_open(&in_iovec);
895 retval = do_create(&in_iovec);
900 retval = do_create_others(header.type, &in_iovec);
903 v9fs_string_init(&path);
904 v9fs_string_init(&oldpath);
905 retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ,
906 "ss", &oldpath, &path);
908 retval = link(oldpath.data, path.data);
913 v9fs_string_free(&oldpath);
914 v9fs_string_free(&path);
918 retval = do_stat(header.type, &in_iovec, &out_iovec);
921 retval = do_readlink(&in_iovec, &out_iovec);
924 v9fs_string_init(&path);
925 retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ,
928 retval = chmod(path.data, mode);
933 v9fs_string_free(&path);
936 v9fs_string_init(&path);
937 retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sdd", &path,
940 retval = lchown(path.data, uid, gid);
945 v9fs_string_free(&path);
948 v9fs_string_init(&path);
949 retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sq",
952 retval = truncate(path.data, offset);
957 v9fs_string_free(&path);
960 v9fs_string_init(&path);
961 retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sqqqq", &path,
962 &spec[0].tv_sec, &spec[0].tv_nsec,
963 &spec[1].tv_sec, &spec[1].tv_nsec);
965 retval = utimensat(AT_FDCWD, path.data, spec,
966 AT_SYMLINK_NOFOLLOW);
971 v9fs_string_free(&path);
974 v9fs_string_init(&path);
975 v9fs_string_init(&oldpath);
976 retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ,
977 "ss", &oldpath, &path);
979 retval = rename(oldpath.data, path.data);
984 v9fs_string_free(&oldpath);
985 v9fs_string_free(&path);
988 v9fs_string_init(&path);
989 retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "s", &path);
991 retval = remove(path.data);
996 v9fs_string_free(&path);
1000 retval = do_getxattr(header.type, &in_iovec, &out_iovec);
1003 v9fs_string_init(&path);
1004 v9fs_string_init(&name);
1005 v9fs_string_init(&value);
1006 retval = proxy_unmarshal(&in_iovec, PROXY_HDR_SZ, "sssdd", &path,
1007 &name, &value, &size, &flags);
1009 retval = lsetxattr(path.data,
1010 name.data, value.data, size, flags);
1015 v9fs_string_free(&path);
1016 v9fs_string_free(&name);
1017 v9fs_string_free(&value);
1019 case T_LREMOVEXATTR:
1020 v9fs_string_init(&path);
1021 v9fs_string_init(&name);
1022 retval = proxy_unmarshal(&in_iovec,
1023 PROXY_HDR_SZ, "ss", &path, &name);
1025 retval = lremovexattr(path.data, name.data);
1030 v9fs_string_free(&path);
1031 v9fs_string_free(&name);
1034 retval = do_getversion(&in_iovec, &out_iovec);
1041 if (process_reply(sock, header.type, &out_iovec, retval) < 0) {
1046 g_free(in_iovec.iov_base);
1047 g_free(out_iovec.iov_base);
1051 int main(int argc, char **argv)
1057 char *sock_name = NULL;
1059 int c, option_index;
1060 #ifdef FS_IOC_GETVERSION
1062 struct statfs st_fs;
1065 fprintf(stderr, "NOTE: The 9p 'proxy' backend is deprecated (since "
1066 "QEMU 8.1) and will be removed in a future version of "
1069 prog_name = g_path_get_basename(argv[0]);
1076 c = getopt_long(argc, argv, "p:nh?f:s:u:g:", helper_opts,
1083 rpath = g_strdup(optarg);
1089 sock = atoi(optarg);
1092 sock_name = g_strdup(optarg);
1095 own_u = atoi(optarg);
1098 own_g = atoi(optarg);
1108 /* Parameter validation */
1109 if ((sock_name == NULL && sock == -1) || rpath == NULL) {
1110 fprintf(stderr, "socket, socket descriptor or path not specified\n");
1115 if (sock_name && sock != -1) {
1116 fprintf(stderr, "both named socket and socket descriptor specified\n");
1121 if (sock_name && (own_u == -1 || own_g == -1)) {
1122 fprintf(stderr, "owner uid:gid not specified, ");
1124 "owner uid:gid specifies who can access the socket file\n");
1129 if (lstat(rpath, &stbuf) < 0) {
1130 fprintf(stderr, "invalid path \"%s\" specified, %s\n",
1131 rpath, strerror(errno));
1135 if (!S_ISDIR(stbuf.st_mode)) {
1136 fprintf(stderr, "specified path \"%s\" is not directory\n", rpath);
1141 if (daemon(0, 0) < 0) {
1142 fprintf(stderr, "daemon call failed\n");
1145 openlog(PROGNAME, LOG_PID, LOG_DAEMON);
1148 do_log(LOG_INFO, "Started\n");
1150 sock = proxy_socket(sock_name, own_u, own_g);
1156 if (chroot(rpath) < 0) {
1157 do_perror("chroot");
1160 if (chdir("/") < 0) {
1165 get_version = false;
1166 #ifdef FS_IOC_GETVERSION
1167 /* check whether underlying FS support IOC_GETVERSION */
1168 retval = statfs("/", &st_fs);
1170 switch (st_fs.f_type) {
1171 case EXT2_SUPER_MAGIC:
1172 case BTRFS_SUPER_MAGIC:
1173 case REISERFS_SUPER_MAGIC:
1174 case XFS_SUPER_MAGIC:
1182 if (init_capabilities() < 0) {
1186 process_requests(sock);
1190 do_log(LOG_INFO, "Done\n");