Use block size provided by the backend in UDF file system.

This commit is contained in:
Andrius Štikonas 2017-09-03 15:39:48 +01:00
parent 7dba4b8245
commit c4628ad715
2 changed files with 1 additions and 33 deletions

View File

@ -27,11 +27,6 @@
#include <QString>
#include <QStringList>
#include <fcntl.h>
#include <linux/fs.h>
#include <sys/ioctl.h>
#include <unistd.h>
namespace FS
{
constexpr qint64 MIN_UDF_BLOCKS = 282;
@ -99,10 +94,6 @@ bool udf::createWithLabel(Report& report, const QString& deviceNode, const QStri
return false;
}
int blkSize = blockSize(report, deviceNode);
if (blkSize == -1)
return false;
// It is not possible to create UDF filesystem without a label or with empty label
// When --lvid or --vid option is not specified, mkudffs use sane default
QStringList labelArgs;
@ -150,7 +141,7 @@ bool udf::createWithLabel(Report& report, const QString& deviceNode, const QStri
// For now format as UDF revision 2.01 for hard disk media type
cmdArgs << QStringLiteral("--media-type=hd");
cmdArgs << QStringLiteral("--udfrev=0x201");
cmdArgs << QStringLiteral("--blocksize=") + QString::number(blkSize);
cmdArgs << QStringLiteral("--blocksize=") + QString::number(sectorSize());
cmdArgs << labelArgs;
cmdArgs << deviceNode;
@ -158,24 +149,4 @@ bool udf::createWithLabel(Report& report, const QString& deviceNode, const QStri
return cmd.run(-1) && cmd.exitCode() == 0;
}
int udf::blockSize(Report& report, const QString& deviceNode)
{
// mkudffs from udftools prior to 1.1 is not able to detect logical (sector) size
// and UDF block size must match logical sector size of underlying media
int fd = open(deviceNode.toLocal8Bit().data(), O_RDONLY);
if ( fd < 0 ) {
report.line() << xi18nc("@info:status", "Cannot open device node");
return -1;
}
int blksize;
int ret = ioctl(fd, BLKSSZGET, &blksize);
close(fd);
if ( ret != 0 ) {
report.line() << xi18nc("@info:status", "Cannot read logical (sector) size of device node");
return -1;
}
return blksize;
}
}

View File

@ -76,9 +76,6 @@ public:
public:
static CommandSupportType m_Create;
static bool m_OnlyAsciiLabel;
private:
int blockSize(Report& report, const QString& deviceNode);
};
}