Accepting request 558622 from home:sparschauer:branches:Base:System
fatresize: Fix getting the device name from partition name (boo#959181) OBS-URL: https://build.opensuse.org/request/show/558622 OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=136
This commit is contained in:
parent
c60348fb0e
commit
3c3dbf367e
73
fatresize-fix-getting-dev-name.patch
Normal file
73
fatresize-fix-getting-dev-name.patch
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
From: Sebastian Parschauer <sparschauer@suse.de>
|
||||||
|
Date: Sun, 3 Dec 2017 12:09:44 +0100
|
||||||
|
Subject: Fix getting the device name from partition name
|
||||||
|
References: boo#959181
|
||||||
|
Patch-mainline: submitted, https://github.com/ya-mouse/fatresize/pull/4
|
||||||
|
|
||||||
|
There are many partition device names like e.g. /dev/mmcblk0p1 where
|
||||||
|
it is not enough to trim the trailing digits to get the disk device
|
||||||
|
name. Using open() here would depend on a POSIX platform. So do it
|
||||||
|
like _ped_device_probe() and silence libparted exceptions and try
|
||||||
|
to get the device with ped_device_get(). Trim further trailing
|
||||||
|
characters until libparted finds it. Print an error and exit if
|
||||||
|
the partition name is invalid.
|
||||||
|
|
||||||
|
Fixes #2
|
||||||
|
|
||||||
|
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
|
||||||
|
---
|
||||||
|
fatresize/fatresize.c | 29 +++++++++++++++++++++++++++++
|
||||||
|
1 file changed, 29 insertions(+)
|
||||||
|
|
||||||
|
--- a/fatresize/fatresize.c
|
||||||
|
+++ b/fatresize/fatresize.c
|
||||||
|
@@ -9,6 +9,7 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
+#include <parted/parted.h>
|
||||||
|
#include <parted/device.h>
|
||||||
|
#include <parted/filesys.h>
|
||||||
|
|
||||||
|
@@ -79,6 +80,18 @@ resize(const char* disk_device, int part
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
+/* Code parts have been taken from _ped_device_probe(). */
|
||||||
|
+static void
|
||||||
|
+probe_device(PedDevice **dev, const char *path)
|
||||||
|
+{
|
||||||
|
+ ped_exception_fetch_all();
|
||||||
|
+ *dev = ped_device_get(path);
|
||||||
|
+ if (!*dev)
|
||||||
|
+ ped_exception_catch();
|
||||||
|
+ ped_exception_leave_all();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
int
|
||||||
|
main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
@@ -126,6 +139,22 @@ main(int argc, char** argv)
|
||||||
|
disk_device = strndup(argv[1], pos - argv[1] + 1);
|
||||||
|
partition_number = strtol(pos + 1, NULL, 10);
|
||||||
|
|
||||||
|
+ PedDevice *peddev = NULL;
|
||||||
|
+ /* check if the device really exists */
|
||||||
|
+ while (pos != argv[1] && *pos != '/' && !peddev)
|
||||||
|
+ {
|
||||||
|
+ disk_device[pos - argv[1] + 1] = '\0';
|
||||||
|
+ probe_device(&peddev, disk_device);
|
||||||
|
+ --pos;
|
||||||
|
+ }
|
||||||
|
+ if (!peddev)
|
||||||
|
+ {
|
||||||
|
+ free(disk_device);
|
||||||
|
+ fprintf(stderr, "invalid device\n");
|
||||||
|
+ exit(EXIT_FAILURE);
|
||||||
|
+ }
|
||||||
|
+ ped_device_destroy(peddev);
|
||||||
|
+
|
||||||
|
if (argc == 3)
|
||||||
|
{
|
||||||
|
char* endptr = NULL;
|
@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Dec 19 17:23:10 UTC 2017 - sparschauer@suse.de
|
||||||
|
|
||||||
|
- fatresize: Fix getting the device name from partition name
|
||||||
|
(boo#959181)
|
||||||
|
- add: fatresize-fix-getting-dev-name.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Nov 21 09:26:23 UTC 2017 - sebastian.parschauer@suse.com
|
Tue Nov 21 09:26:23 UTC 2017 - sebastian.parschauer@suse.com
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ Patch58: parted-add-ignore-busy-option.patch
|
|||||||
Patch59: parted-fix-resizepart-and-rm-command.patch
|
Patch59: parted-fix-resizepart-and-rm-command.patch
|
||||||
# Fatresize
|
# Fatresize
|
||||||
Patch100: parted-fatresize-autoconf.patch
|
Patch100: parted-fatresize-autoconf.patch
|
||||||
|
Patch101: fatresize-fix-getting-dev-name.patch
|
||||||
# Upstream tests patches
|
# Upstream tests patches
|
||||||
Patch150: tests-set-optimal-blocks-for-scsi_debug.patch
|
Patch150: tests-set-optimal-blocks-for-scsi_debug.patch
|
||||||
Patch151: tests-increase-scsi_debug-tmo.patch
|
Patch151: tests-increase-scsi_debug-tmo.patch
|
||||||
@ -194,6 +195,7 @@ to develop applications that require these.
|
|||||||
%patch58 -p1
|
%patch58 -p1
|
||||||
%patch59 -p1
|
%patch59 -p1
|
||||||
%patch100 -p1
|
%patch100 -p1
|
||||||
|
%patch101 -p1
|
||||||
%patch150 -p1
|
%patch150 -p1
|
||||||
%patch151 -p1
|
%patch151 -p1
|
||||||
%patch152 -p1
|
%patch152 -p1
|
||||||
|
Loading…
Reference in New Issue
Block a user