File indexing completed on 2024-04-28 05:45:53

0001 /*
0002     SPDX-FileCopyrightText: Tomaz Canabrava <tcanabrava@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-3.0-or-later
0005 */
0006 
0007 #include "jobs/changepermissionsjob.h"
0008 
0009 #include "core/lvmdevice.h"
0010 #include "core/partition.h"
0011 #include "fs/luks.h"
0012 
0013 #include "util/report.h"
0014 
0015 #include <KLocalizedString>
0016 
0017 /** Creates a new CreateVolumeGroupJob
0018  * @param permission the new permission for the partition, in chmod style.
0019  * @param partition the partition to change the permission.
0020  */
0021 ChangePermissionJob::ChangePermissionJob(Partition& partition) :
0022     Job(),
0023     m_Partition(partition)
0024 {
0025 }
0026 
0027 bool ChangePermissionJob::run(Report& parent)
0028 {
0029     bool rval = false;
0030 
0031     auto &fs = m_Partition.fileSystem();
0032 
0033     Report* report = jobStarted(parent);
0034 
0035     if (m_Partition.roles().has(PartitionRole::Luks)) {
0036         auto &luksFs = static_cast<FS::luks&>(fs);
0037         rval = luksFs.execChangePosixPermission(*report, m_Partition.deviceNode());
0038     }
0039     else
0040         rval = fs.execChangePosixPermission(*report, m_Partition.deviceNode());
0041 
0042     jobFinished(*report, rval);
0043 
0044     return rval;
0045 }
0046 
0047 QString ChangePermissionJob::description() const
0048 {
0049     return xi18nc("@info/plain", "Change the permissions of: <filename>%1</filename> to %2", m_Partition.deviceNode(), m_permissions);
0050 }