#include #include #include #include #include #include #include #include #include struct fs_sysfs_path { __u8 len; __u8 name[128]; }; #define FS_IOC_GETFSSYSFSPATH _IOR(0x15, 1, struct fs_sysfs_path) void die(const char *fmt, ...) { va_list args; va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); fputc('\n', stderr); _exit(EXIT_FAILURE); } int main(int argc, char *argv[]) { const char *path = argv[1] ?: "."; int fd = open(path, O_RDONLY); if (fd < 0) die("Error opening %s: %m\n", path); struct fs_sysfs_path sysfspath; if (ioctl(fd, FS_IOC_GETFSSYSFSPATH, (unsigned long) &sysfspath)) die("FS_IOC_GETFSSYSFSPATH error: %m\n"); write(STDOUT_FILENO, sysfspath.name, sysfspath.len); }