File indexing completed on 2024-12-01 13:48:43
0001 /* 0002 SPDX-FileCopyrightText: 2019-2020 Fabian Vogt <fabian@ritter-vogt.de> 0003 SPDX-FileCopyrightText: 2019-2020 Alexander Saoutkin <a.saoutkin@gmail.com> 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 #include <fuse_lowlevel.h> 0007 0008 #include <QCoreApplication> 0009 0010 #include <KAboutData> 0011 0012 #include "kiofuseservice.h" 0013 #include "kiofuseversion.h" 0014 0015 // Put all custom arguments in here. 0016 // @see https://github.com/libfuse/libfuse/wiki/Option-Parsing 0017 struct kiofuse_config { 0018 int useFileJob = 1; // on by default 0019 }; 0020 0021 #define KIOFUSE_OPT(t, p, v) { t, offsetof(struct kiofuse_config, p), v } 0022 0023 static struct fuse_opt kiofuse_opts[] = { 0024 KIOFUSE_OPT("--disable-filejob-io", useFileJob, 0), 0025 FUSE_OPT_END 0026 }; 0027 0028 #undef KIOFUSE_OPT 0029 0030 int main(int argc, char *argv[]) 0031 { 0032 struct fuse_args args = FUSE_ARGS_INIT(argc, argv); 0033 struct kiofuse_config conf; 0034 struct fuse_cmdline_opts opts; 0035 0036 fuse_opt_parse(&args, &conf, kiofuse_opts, nullptr); 0037 if (fuse_parse_cmdline(&args, &opts) != 0) 0038 return 1; 0039 0040 if (opts.show_help) 0041 { 0042 printf("Usage: %s [options] <mountpoint>\n\n", argv[0]); 0043 fuse_cmdline_help(); 0044 fuse_lowlevel_help(); 0045 printf(" --disable-filejob-io Don't use FileJob-based (KIO::open) I/O\n"); 0046 return 0; 0047 } 0048 else if (opts.show_version) 0049 { 0050 printf("KIO FUSE version %s\n", KIOFUSE_VERSION_STRING); 0051 printf("FUSE library version %s\n", fuse_pkgversion()); 0052 fuse_lowlevel_version(); 0053 return 0; 0054 } 0055 0056 QCoreApplication a(argc, argv); 0057 KIOFuseService kiofuseservice; 0058 0059 KAboutData about(QStringLiteral("kiofuse"), QStringLiteral("FUSE Interface for KIO"), QStringLiteral(KIOFUSE_VERSION_STRING)); 0060 KAboutData::setApplicationData(about); 0061 0062 kiofuseservice.kiofusevfs.setUseFileJob(conf.useFileJob); 0063 if(!kiofuseservice.start(args, QString::fromUtf8(opts.mountpoint), opts.foreground)) 0064 return 1; 0065 0066 fuse_opt_free_args(&args); 0067 0068 return a.exec(); 0069 }