Merge pull request #12162 from Rmys/master

libblockdev, udisks2 ver. bump
This commit is contained in:
Rmys
2023-07-17 19:44:09 +03:00
committed by GitHub
5 changed files with 196 additions and 13 deletions
+5 -3
View File
@@ -9,17 +9,19 @@ from pisi.actionsapi import pisitools
from pisi.actionsapi import shelltools
from pisi.actionsapi import get
shelltools.export("python2", "/usr/bin/python2.7")
# shelltools.export("python2", "/usr/bin/python2.7")
def setup():
# shelltools.system("sed 's/g_memdup/&2/' -i \
# src/lib/plugin_apis/vdo.{c,api} \
# src/plugins/vdo.c")
shelltools.system("sh ./autogen.sh")
shelltools.system("sed -i 's|python2-config|python2.7-config|g' configure")
# shelltools.system("sh ./autogen.sh")
autotools.autoreconf("-ivf")
# shelltools.system("sed -i 's|python2-config|python2.7-config|g' configure")
autotools.configure("--without-gtk-doc \
--without-nvdimm \
--with-python3 \
--without-dm")
pisitools.dosed("libtool", " -shared ", " -Wl,-O1,--as-needed -shared ")
@@ -0,0 +1,160 @@
diff --git a/src/plugins/fs/generic.c b/src/plugins/fs/generic.c
index 4406d5c..075af7e 100644
--- a/src/plugins/fs/generic.c
+++ b/src/plugins/fs/generic.c
@@ -229,7 +229,7 @@ const BDFSInfo fs_info[BD_FS_LAST_FS] = {
.repair_util = "ntfsfix",
.resize_util = "ntfsresize",
.label_util = "ntfslabel",
- .info_util = "ntfscluster",
+ .info_util = "ntfsinfo",
.uuid_util = "ntfslabel" },
/* F2FS */
{ .type = "f2fs",
diff --git a/src/plugins/fs/ntfs.c b/src/plugins/fs/ntfs.c
index 517d1cf..1aa503c 100644
--- a/src/plugins/fs/ntfs.c
+++ b/src/plugins/fs/ntfs.c
@@ -20,6 +20,7 @@
#include <blockdev/utils.h>
#include <check_deps.h>
#include <string.h>
+#include <stdio.h>
#include "ntfs.h"
#include "fs.h"
@@ -36,8 +37,8 @@ static GMutex deps_check_lock;
#define DEPS_NTFSRESIZE_MASK (1 << DEPS_NTFSRESIZE)
#define DEPS_NTFSLABEL 3
#define DEPS_NTFSLABEL_MASK (1 << DEPS_NTFSLABEL)
-#define DEPS_NTFSCLUSTER 4
-#define DEPS_NTFSCLUSTER_MASK (1 << DEPS_NTFSCLUSTER)
+#define DEPS_NTFSINFO 4
+#define DEPS_NTFSINFO_MASK (1 << DEPS_NTFSINFO)
#define DEPS_LAST 5
@@ -46,7 +47,7 @@ static const UtilDep deps[DEPS_LAST] = {
{"ntfsfix", NULL, NULL, NULL},
{"ntfsresize", NULL, NULL, NULL},
{"ntfslabel", NULL, NULL, NULL},
- {"ntfscluster", NULL, NULL, NULL},
+ {"ntfsinfo", NULL, NULL, NULL},
};
static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
@@ -55,7 +56,7 @@ static guint32 fs_mode_util[BD_FS_MODE_LAST+1] = {
DEPS_NTFSFIX_MASK, /* check */
DEPS_NTFSFIX_MASK, /* repair */
DEPS_NTFSLABEL_MASK, /* set-label */
- DEPS_NTFSCLUSTER_MASK, /* query */
+ DEPS_NTFSINFO_MASK, /* query */
DEPS_NTFSRESIZE_MASK, /* resize */
DEPS_NTFSLABEL_MASK /* set-uuid */
};
@@ -356,7 +357,7 @@ gboolean bd_fs_ntfs_resize (const gchar *device, guint64 new_size, GError **erro
* Tech category: %BD_FS_TECH_NTFS-%BD_FS_TECH_MODE_QUERY
*/
BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) {
- const gchar *args[3] = {"ntfscluster", device, NULL};
+ const gchar *args[4] = {"ntfsinfo", "-m", device, NULL};
gboolean success = FALSE;
gchar *output = NULL;
BDFSNtfsInfo *ret = NULL;
@@ -365,8 +366,9 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) {
gchar *val_start = NULL;
g_autofree gchar* mountpoint = NULL;
GError *l_error = NULL;
+ size_t cluster_size = 0;
- if (!check_deps (&avail_deps, DEPS_NTFSCLUSTER_MASK, deps, DEPS_LAST, &deps_check_lock, error))
+ if (!check_deps (&avail_deps, DEPS_NTFSINFO_MASK, deps, DEPS_LAST, &deps_check_lock, error))
return NULL;
mountpoint = bd_fs_get_mountpoint (device, &l_error);
@@ -400,8 +402,9 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) {
lines = g_strsplit (output, "\n", 0);
g_free (output);
line_p = lines;
+
/* find the beginning of the (data) section we are interested in */
- while (line_p && *line_p && !g_str_has_prefix (*line_p, "bytes per volume"))
+ while (line_p && *line_p && !strstr (*line_p, "Cluster Size"))
line_p++;
if (!line_p || !(*line_p)) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse NTFS file system information");
@@ -410,12 +413,12 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) {
return NULL;
}
- /* extract data from something like this: "bytes per volume : 998240256" */
+ /* extract data from something like this: "Cluster Size: 4096" */
val_start = strchr (*line_p, ':');
val_start++;
- ret->size = g_ascii_strtoull (val_start, NULL, 0);
+ cluster_size = g_ascii_strtoull (val_start, NULL, 0);
- while (line_p && *line_p && !g_str_has_prefix (*line_p, "bytes of free space"))
+ while (line_p && *line_p && !strstr (*line_p, "Volume Size in Clusters"))
line_p++;
if (!line_p || !(*line_p)) {
g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse NTFS file system information");
@@ -424,10 +427,27 @@ BDFSNtfsInfo* bd_fs_ntfs_get_info (const gchar *device, GError **error) {
return NULL;
}
- /* extract data from something like this: "bytes of free space : 992759808" */
+ /* extract data from something like this: "Volume Size in Clusters: 15314943" */
val_start = strchr (*line_p, ':');
val_start++;
- ret->free_space = g_ascii_strtoull (val_start, NULL, 0);
+ ret->size = g_ascii_strtoull (val_start, NULL, 0) * cluster_size;
+
+ while (line_p && *line_p && !strstr (*line_p, "Free Clusters"))
+ line_p++;
+ if (!line_p || !(*line_p)) {
+ g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_PARSE, "Failed to parse NTFS file system information");
+ g_strfreev (lines);
+ bd_fs_ntfs_info_free (ret);
+ return NULL;
+ }
+
+ /* extract data from something like this: "Free Clusters: 7812655 (51,0%)" */
+ val_start = strchr (*line_p, ':');
+ val_start++;
+ ret->free_space = g_ascii_strtoull (val_start, NULL, 0) * cluster_size;
+
+ printf("size: %lu\n", ret->size);
+ printf("free_space: %lu\n", ret->free_space);
g_strfreev (lines);
diff --git a/tests/fs_tests/ntfs_test.py b/tests/fs_tests/ntfs_test.py
index c04e39d..ff0fc31 100644
--- a/tests/fs_tests/ntfs_test.py
+++ b/tests/fs_tests/ntfs_test.py
@@ -56,9 +56,9 @@ class NTFSTestAvailability(NTFSNoDevTestCase):
with self.assertRaisesRegex(GLib.GError, "The 'ntfsfix' utility is not available"):
BlockDev.fs_is_tech_avail(BlockDev.FSTech.NTFS, BlockDev.FSTechMode.REPAIR)
- # now try without ntfscluster
- with utils.fake_path(all_but="ntfscluster"):
- with self.assertRaisesRegex(GLib.GError, "The 'ntfscluster' utility is not available"):
+ # now try without ntfsinfo
+ with utils.fake_path(all_but="ntfsinfo"):
+ with self.assertRaisesRegex(GLib.GError, "The 'ntfsinfo' utility is not available"):
BlockDev.fs_is_tech_avail(BlockDev.FSTech.NTFS, BlockDev.FSTechMode.QUERY)
# now try without ntfsresize
diff --git a/tests/utils.py b/tests/utils.py
index c498c10..ef21507 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -81,7 +81,7 @@ ALL_UTILS = {"lvm", "btrfs", "mkswap", "swaplabel", "multipath", "mpathconf", "d
"mke2fs", "e2fsck", "tune2fs", "dumpe2fs", "resize2fs",
"mkfs.f2fs", "fsck.f2fs", "fsck.f2fs", "dump.f2fs", "resize.f2fs",
"mkfs.nilfs2", "nilfs-tune", "nilfs-resize",
- "mkntfs", "ntfsfix", "ntfsresize", "ntfslabel", "ntfscluster",
+ "mkntfs", "ntfsfix", "ntfsresize", "ntfslabel", "ntfsinfo",
"mkfs.vfat", "fatlabel", "fsck.vfat", "vfat-resize",
"mkfs.xfs", "xfs_db", "xfs_repair", "xfs_admin", "xfs_growfs"}
+13 -1
View File
@@ -12,13 +12,14 @@
<IsA>app</IsA>
<Summary>A library for manipulating block devices</Summary>
<Description>Blok cihazlarını değiştirmek için bir kütüphane</Description>
<Archive sha1sum="1b4f4214ad7a0c221aa09e8020158c4e8ccaa419" type="targz">https://github.com/storaged-project/libblockdev/archive/refs/tags/2.28-1.tar.gz</Archive>
<Archive sha1sum="f0e90196c7cd67c3dfaea5f57cf956f06ed25173" type="targz">https://github.com/storaged-project/libblockdev/archive/refs/tags/3.0.1-1.tar.gz</Archive>
<BuildDependencies>
<Dependency>nss-devel</Dependency>
<Dependency>mdadm</Dependency>
<Dependency>util-linux</Dependency>
<Dependency>glib2-devel</Dependency>
<Dependency>parted-devel</Dependency>
<Dependency>libnvme-devel</Dependency>
<Dependency>libyaml-devel</Dependency>
<Dependency>python-devel</Dependency>
<Dependency>python3-devel</Dependency>
@@ -31,6 +32,9 @@
<Dependency>device-mapper-devel</Dependency>
<Dependency>gobject-introspection-devel</Dependency>
</BuildDependencies>
<Patches>
<Patch level="1">aefd677.patch</Patch>
</Patches>
</Source>
<Package>
@@ -42,6 +46,7 @@
<Dependency>eudev</Dependency>
<Dependency>parted</Dependency>
<Dependency>libyaml</Dependency>
<Dependency>libnvme</Dependency>
<Dependency>libkmod</Dependency>
<Dependency>volume_key</Dependency>
<Dependency>libbytesize</Dependency>
@@ -73,6 +78,13 @@
</Package>
<History>
<Update release="8">
<Date>2023-07-12</Date>
<Version>3.0.1</Version>
<Comment>Version bump.</Comment>
<Name>Mustafa Cinasal</Name>
<Email>muscnsl@gmail.com</Email>
</Update>
<Update release="7">
<Date>2022-11-05</Date>
<Version>2.28</Version>
@@ -1,10 +1,11 @@
diff -Nuar a/src/udiskslinuxfilesystem.c b/src/udiskslinuxfilesystem.c
--- a/src/udiskslinuxfilesystem.c 2020-05-26 12:59:20.000000000 +0000
+++ b/src/udiskslinuxfilesystem.c 2020-07-09 13:47:11.230931796 +0000
@@ -300,6 +300,7 @@
"vfat",
"exfat",
--- a/src/udiskslinuxfilesystem.c 2023-06-28 18:13:57.000000000 +0300
+++ b/src/udiskslinuxfilesystem.c 2023-07-12 15:01:02.769714651 +0300
@@ -373,6 +373,7 @@
"nilfs2",
"ntfs",
"ntfs3",
+ "ntfs-3g",
NULL,
};
"udf",
"reiserfs",
"reiser4",
+10 -2
View File
@@ -13,7 +13,7 @@
<IsA>app:console</IsA>
<Summary>Disk Management Service</Summary>
<Description>udisks provides a daemon, API and command line tools for managing disk devices attached to the system.</Description>
<Archive sha1sum="e6f21e90456360723d80265c4d3372eb88ef7a6e" type="tarbz2">https://github.com/storaged-project/udisks/releases/download/udisks-2.9.4/udisks-2.9.4.tar.bz2</Archive>
<Archive sha1sum="4afc5b110a2313f23537a01855529864927934cf" type="tarbz2">https://github.com/storaged-project/udisks/releases/download/udisks-2.10.0/udisks-2.10.0.tar.bz2</Archive>
<AdditionalFiles>
<!-- <AdditionalFile target="po/tr.po">tr.po</AdditionalFile> -->
</AdditionalFiles>
@@ -40,7 +40,7 @@
<Dependency>ntfs-3g</Dependency>
<Dependency>gptfdisk</Dependency>
<Dependency>btrfs-progs-devel</Dependency>
<Dependency versionFrom="2.25">libblockdev-devel</Dependency>
<Dependency versionFrom="3.0.1">libblockdev-devel</Dependency>
</BuildDependencies>
<Patches>
<!--Patch level="1">udisks-2.0.91-udf-dvd-fix-dmask.patch</Patch-->
@@ -89,6 +89,7 @@
<Path fileType="data">/var/lib/</Path>
<Path fileType="data">/run/udisks</Path>
<Path fileType="data">/usr/share/dbus-1/interfaces/*.xml</Path>
<Path fileType="data">/usr/share/zsh/site-functions/_udisks2</Path>
</Files>
</Package>
@@ -117,6 +118,13 @@
</Package>
<History>
<Update release="11">
<Date>2023-07-12</Date>
<Version>2.10.0</Version>
<Comment>Version bump.</Comment>
<Name>Mustafa Cinasal</Name>
<Email>muscnsl@gmail.com</Email>
</Update>
<Update release="10">
<Date>2021-11-21</Date>
<Version>2.9.4</Version>