Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.16.0)

# Version setup
set(OPENBSDISKS_VERSION_MAJOR "0")
set(OPENBSDISKS_VERSION_MINOR "2")
set(OPENBSDISKS_VERSION_PATCH "3")
set(OPENBSDISKS_VERSION_MINOR "3")
set(OPENBSDISKS_VERSION_PATCH "0")
set(OPENBSDISKS_VERSION "${OPENBSDISKS_VERSION_MAJOR}.${OPENBSDISKS_VERSION_MINOR}.${OPENBSDISKS_VERSION_PATCH}")

project(openbsdisks2
Expand Down Expand Up @@ -40,6 +40,7 @@ set(SOURCE
src/manageradaptor.cpp
src/objectmanager.cpp

src/cd_handler.cpp
src/disk_thread.cpp
src/disk_label.cpp
)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright 2016 Gleb Popov <6yearold@gmail.com>
Copyright 2020 Rafael Sadowski <rafael@sizeofvoid.org>
Copyright 2020-2021 Rafael Sadowski <rafael@sizeofvoid.org>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ An UDisks2 service implementation for OpenBSD forked from FreeBSD (bsdutils/bsdi
The sourcecode based on commit [3d3439348ba00ae972e146c5bf28cb42949e24f](https://foss.heptapod.net/bsdutils/bsdisks/-/commit/93d3439348ba00ae972e146c5bf28cb42949e24f) from [bsdutils/bsdisks](https://foss.heptapod.net/bsdutils/bsdisks).

### Feature List
- [x] Simple DBus org.freedesktop.UDisks2.service
- [X] Simple DBus org.freedesktop.UDisks2.service
- [X] Provides `org.freedesktop.UDisks2.Block`
- [X] Provides `org.freedesktop.UDisks2.Drive`
- [X] Provides `org.freedesktop.UDisks2.Filesystem` (Not all information yet)
- [X] Logging via `stdout` and syslog
- [ ] cd(4) support
- [x] mount(2), umount(2) support (ffs only)
- [X] cd(4) support
- [X] mount(2), umount(2) support (ffs only)
- [ ] Privilege separation
- [ ] Device information updates

Expand Down
6 changes: 5 additions & 1 deletion src/blockfilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void BlockFilesystem::setFilesystem(const QString& fs)
bool BlockFilesystem::isFilesystemSupportedToMount() const
{
return (filesystem == "ffs" || filesystem == "ext2fs" || filesystem == "ntfs" ||
filesystem == "msdos");
filesystem == "msdos" || filesystem == "cd9660");
}

const QString BlockFilesystem::getMountCommand() const
Expand All @@ -245,6 +245,8 @@ const QString BlockFilesystem::getMountCommand() const
mountProg = QStringLiteral("/sbin/mount_ntfs");
} else if (filesystem == "ntfs") {
mountProg = QStringLiteral("/sbin/mount_msdos");
} else if (filesystem == "cd9660") {
mountProg = QStringLiteral("/sbin/mount_cd9660");
}
return mountProg;
}
Expand All @@ -260,6 +262,8 @@ const QStringList BlockFilesystem::getMountOptions() const
mountOps << QStringLiteral("-orw");
} else if (filesystem == "ntfs") {
mountOps << QStringLiteral("-oro");
} else if (filesystem == "cd9660") {
mountOps << QStringLiteral("-oro");
}
return mountOps;
}
2 changes: 2 additions & 0 deletions src/blockfilesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <QStringList>
#include <QVariantMap>

#include <memory>

class Block;

class BlockFilesystem
Expand Down
2 changes: 2 additions & 0 deletions src/blockparttable.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <QString>
#include <QStringList>

#include <memory>

class BlockPartTable
{
public:
Expand Down
47 changes: 47 additions & 0 deletions src/cd_handler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2021 Rafael Sadowski <rafael@sizeofvoid.org>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/

#include "cd_handler.h"

#include "drive.h"

#include <QStringList>

CdHandler::CdHandler(const QString& dev)
: DiskLabel(dev)
{
analyseDev(dev);
}

void CdHandler::analyseDev(const QString& dev)
{
DiskLabel::analyseDev(dev);
if (getDrive())
getDrive()->setRemovable(true);
}

/**
* return a list of all possible device names
* /dev/cd[0-9][a-p] block mode CD-ROM devices
*/
QStringList const CdHandler::getBlockCDROMdevices()
{
QStringList devs;
for (const QString& dev : QStringList({"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}))
devs << "rcd" + dev;
return devs;
}
44 changes: 44 additions & 0 deletions src/cd_handler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2021 Rafael Sadowski <rs@rsadowski.de>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/

#pragma once

#include "drive.h"

#include "disk_label.h"

class QString;

/**
* disklabel – read disk pack label
*/
class CdHandler : public DiskLabel
{
public:
CdHandler(const QString&);

CdHandler() = default;
~CdHandler() = default;

static QStringList const getBlockCDROMdevices();

private:
void analyseDev(const QString&) override;
};

using TCdHandler = std::shared_ptr<CdHandler>;
using TCdHandlerVec = std::vector<TCdHandler>;
6 changes: 4 additions & 2 deletions src/disk_label.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ class DiskLabel
{
public:
DiskLabel() = default;
virtual ~DiskLabel() = default;

DiskLabel(const QString&);

bool isValid() const;
TDrive getDrive() const;
QString getDeviceName() const;

private:
void analyseDev(const QString&);
protected:
virtual void analyseDev(const QString&);
bool isValidFileSysetem(u_int8_t) const;

void createDrive(const QString&);
Expand Down
8 changes: 8 additions & 0 deletions src/disk_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ void DiskThread::run()

void DiskThread::check()
{
for (auto const& name : CdHandler::getBlockCDROMdevices()) {
auto cd = std::make_shared<CdHandler>(name);
if (cd->isValid()) {
m_cds.push_back(cd);
emit deviceAdded(cd->getDrive());
}
}

// "sd0:6e6c992178f67d41,sd2:0f191ebc5bc2aa61,sd1:"
const QString disks = readDisknames();
const auto devNameUuids = getCurrentDev(disks);
Expand Down
2 changes: 2 additions & 0 deletions src/disk_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QThread>
#include <QTimer>

#include "cd_handler.h"
#include "disk_label.h"

class DiskThread : public QThread
Expand All @@ -46,4 +47,5 @@ private slots:

QTimer* m_t;
TDiskLabelVec diskLabels;
TCdHandlerVec m_cds;
};
4 changes: 2 additions & 2 deletions src/drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ void Drive::setDuid(const QUuid& duid)

bool Drive::ejectable() const
{
return isRemovable;
return removable();
}

bool Drive::removable() const
{
return isRemovable;
return optical() || isRemovable;
}

bool Drive::mediaRemovable() const
Expand Down