File indexing completed on 2024-04-28 09:41:27

0001 /*
0002     SPDX-FileCopyrightText: 2018 Andrius Štikonas <andrius@stikonas.eu>
0003     SPDX-FileCopyrightText: 2019 Shubham Jangra <aryan100jangid@gmail.com>
0004     SPDX-FileCopyrightText: 2019 Albert Astals Cid <aacid@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-3.0-or-later
0007 */
0008 
0009 
0010 #include "helpers.h"
0011 #include "backend/corebackendmanager.h"
0012 #include "util/externalcommand.h"
0013 
0014 #include <QCoreApplication>
0015 #include <QDebug>
0016 #include <QThread>
0017 
0018 class runcmd : public QThread
0019 {
0020     public:
0021     void run() override
0022     {
0023         ExternalCommand blkidCmd(QStringLiteral("blkid"), {});
0024 
0025         // ExternalCommadHelper will refuse to run this or any other command which is not whitelisted.
0026         // See src/util/externalcommand_whitelist.h for whitelisted commands.
0027         blkidCmd.run();
0028         qDebug().noquote() << blkidCmd.output();
0029     }
0030 };
0031 
0032 class runcmd2 : public QThread
0033 {
0034     public:
0035     void run() override
0036     {
0037         ExternalCommand lsblkCmd(QStringLiteral("lsblk"), { QStringLiteral("--nodeps"), QStringLiteral("--json") });
0038         lsblkCmd.run();
0039         qDebug().noquote() << lsblkCmd.output();
0040     }
0041 };
0042 
0043 
0044 int main( int argc, char **argv )
0045 {
0046     QCoreApplication app(argc, argv);
0047     KPMCoreInitializer i(QStringLiteral("pmsfdiskbackendplugin"));
0048 
0049     runcmd a;
0050     runcmd2 b;
0051 
0052     a.start();
0053     a.wait();
0054 
0055     b.start();
0056     b.wait();
0057 
0058     return 0;
0059 }