Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
aports
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
639
Issues
639
List
Boards
Labels
Service Desk
Milestones
Merge Requests
193
Merge Requests
193
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
aports
Commits
39171d2d
Commit
39171d2d
authored
Jun 15, 2016
by
Natanael Copa
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
main/util-linux: backport libblkid cdrom probe patch
ref
#5697
parent
6ec54370
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
1 deletion
+90
-1
main/util-linux/APKBUILD
main/util-linux/APKBUILD
+5
-1
main/util-linux/libblkid-reduce-probing-area-for-crazy-CDROMs.patch
...linux/libblkid-reduce-probing-area-for-crazy-CDROMs.patch
+85
-0
No files found.
main/util-linux/APKBUILD
View file @
39171d2d
...
...
@@ -8,7 +8,7 @@ case $pkgver in
*
.
*
)
_v
=
$pkgver
;;
esac
pkgrel
=
2
pkgrel
=
3
pkgdesc
=
"Random collection of Linux utilities"
url
=
"http://git.kernel.org/cgit/utils/util-linux/util-linux.git"
arch
=
"all"
...
...
@@ -19,6 +19,7 @@ makedepends="zlib-dev sed ncurses-dev tar autoconf automake libtool python-dev l
install
=
options
=
"suid"
source
=
"http://www.kernel.org/pub/linux/utils/util-linux/v
${
_v
}
/util-linux-
$pkgver
.tar.xz
libblkid-reduce-probing-area-for-crazy-CDROMs.patch
ttydefaults.h
"
subpackages
=
"
$pkgname
-doc
$pkgname
-dev libuuid libblkid libmount
...
...
@@ -152,8 +153,11 @@ _py() {
}
md5sums
=
"e534e6ccc49107e5d31c329af798ef7d util-linux-2.28.tar.xz
ee12cce6423e6f7ea4c9c438989e77d7 libblkid-reduce-probing-area-for-crazy-CDROMs.patch
6196f1ce853dfaf717569c1e35555d6d ttydefaults.h"
sha256sums
=
"395847e2a18a2c317170f238892751e73a57104565344f8644090c8b091014bb util-linux-2.28.tar.xz
12b6434a229d08c81f45735cac50e9003908f3ad974c59cec93ddf57700077f3 libblkid-reduce-probing-area-for-crazy-CDROMs.patch
46faf1198bd884d12c5d45019a5fec8dfdefeae6721d8c9f3da89921acdb2a6d ttydefaults.h"
sha512sums
=
"a1f911bdfda5985de87105d39501e501a5f9ec0fe6a433e3f2fed9a80e104342bb4a7e0e6dc9b7d677d5429249f05b343cb5370b0ea0e068dc889699d4ec1f8a util-linux-2.28.tar.xz
ec27d4227f7e0f08198ecf00f4c7da379ed588eb05835c318322bec26841868e51337c5710706237a7a3358aa0db6d4514c8f2444d02b2bd800f1c7f9e9570c2 libblkid-reduce-probing-area-for-crazy-CDROMs.patch
876bb9041eca1b2cca1e9aac898f282db576f7860aba690a95c0ac629d7c5b2cdeccba504dda87ff55c2a10b67165985ce16ca41a0694a267507e1e0cafd46d9 ttydefaults.h"
main/util-linux/libblkid-reduce-probing-area-for-crazy-CDROMs.patch
0 → 100644
View file @
39171d2d
From bfebe74e3babe8c188a51269acc2673f1aea283f Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 19 Apr 2016 12:39:05 +0200
Subject: [PATCH] libblkid: reduce probing area for crazy CDROMs
Linux kernel reports devices greater than area readable by read(2).
The readable area is usually 2-3 CD blocks smaller (CD block is
2048-bytes) than size returned by BLKGETSIZE. This patch checks for
this issues to avoid I/O errors in probing functions.
Reported-by: Thomas Schmitt <scdbackup@gmx.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libblkid/src/probe.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 0c8625c..0455c37 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -752,6 +752,51 @@
int blkid_probe_is_cdrom(blkid_probe pr)
return pr && (pr->flags & BLKID_FL_CDROM_DEV);
}
+static int is_sector_readable(int fd, uint64_t sector)
+{
+ char buf[512];
+ ssize_t sz;
+
+ if (blkid_llseek(fd, sector * 512, SEEK_SET) < 0)
+ goto failed;
+
+ sz = read(fd, buf, sizeof(buf));
+ if (sz != (ssize_t) sizeof(buf))
+ goto failed;
+
+ return 1;
+failed:
+ DBG(LOWPROBE, ul_debug("CDROM: read sector %ju failed %m", sector));
+ errno = 0;
+ return 0;
+}
+
+/*
+ * Linux kernel reports (BLKGETSIZE) cdrom device size greater than area
+ * readable by read(2). We have to reduce the probing area to avoid unwanted
+ * I/O errors in probing functions. It seems that unreadable are always last 2
+ * or 3 CD blocks (CD block size is 2048 bytes, it means 12 in 512-byte
+ * sectors).
+ */
+static void cdrom_size_correction(blkid_probe pr)
+{
+ uint64_t n, nsectors = pr->size >> 9;
+
+ for (n = nsectors - 12; n < nsectors; n++) {
+ if (!is_sector_readable(pr->fd, n))
+ goto failed;
+ }
+
+ DBG(LOWPROBE, ul_debug("CDROM: full size available"));
+ return;
+failed:
+ /* 'n' is the failed sector, reduce device size to n-1; */
+ DBG(LOWPROBE, ul_debug("CDROM: reduce size from %ju to %ju.",
+ (uintmax_t) pr->size,
+ (uintmax_t) (n - 1) << 9));
+ pr->size = n << 9;
+}
+
/**
* blkid_probe_set_device:
* @pr: probe
@@ -844,8 +889,11 @@
int blkid_probe_set_device(blkid_probe pr, int fd,
else if (S_ISBLK(sb.st_mode) &&
!blkid_probe_is_tiny(pr) &&
blkid_probe_is_wholedisk(pr) &&
- ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0)
+ ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0) {
+
pr->flags |= BLKID_FL_CDROM_DEV;
+ cdrom_size_correction(pr);
+ }
#endif
DBG(LOWPROBE, ul_debug("ready for low-probing, offset=%"PRIu64", size=%"PRIu64"",
algitbot
@root
mentioned in issue
#5697 (closed)
·
Jul 12, 2019
mentioned in issue
#5697 (closed)
mentioned in issue #5697
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment