[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] lsscsi: Fix xchdir(".."); from symlink in /sys/bus/scsi/devices
From:       Markus Gothe <nietzsche () lysator ! liu ! se>
Date:       2017-10-21 17:21:30
Message-ID: C005A5B0-6690-4899-874C-57A12D1B4A46 () lysator ! liu ! se
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/alternative)]


This patch fixes a bug when having more than 1 device exposed by the =
SCSI-layer, notably USB-disks, which creates entries like this.
lrwxrwxrwx    1         0 Oct 20 14:52 1:0:0:0 -> =
../../../devices/platform/xhci-hcd/usb1/1-2/1-2:1.0/host1/target1:0:0/1:0:=
0:0

//Markus - The panama-hat hacker


[Attachment #7 (multipart/mixed)]

[Attachment #9 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html \
charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: \
space; -webkit-line-break: after-white-space;"><div>This patch fixes a bug when \
having more than 1 device exposed by the SCSI-layer, notably USB-disks, which creates \
entries like this.</div><div>lrwxrwxrwx&nbsp;&nbsp;&nbsp; \
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 Oct 20 14:52 1:0:0:0 \
-&gt;&nbsp;../../../devices/platform/xhci-hcd/usb1/1-2/1-2:1.0/host1/target1:0:0/1:0:0:0</div><div></div></body></html>



["lsscsi.patch" (lsscsi.patch)]

--- busybox-1.27.2.old/miscutils/lsscsi.c	2017-07-06 17:14:57.000000000 +0200
+++ busybox-1.27.2/miscutils/lsscsi.c	2017-10-21 19:16:45.000000000 +0200
@@ -25,6 +25,8 @@
 
 #include "libbb.h"
 
+static const char scsi_dir[] ALIGN1 = "/sys/bus/scsi/devices";
+
 static char *get_line(const char *filename, char *buf, unsigned *bufsize_p)
 {
 	unsigned bufsize = *bufsize_p;
@@ -54,7 +56,7 @@
 	struct dirent *de;
 	DIR *dir;
 
-	xchdir("/sys/bus/scsi/devices");
+	xchdir(scsi_dir);
 
 	dir = xopendir(".");
 	while ((de = readdir(dir)) != NULL) {
@@ -113,7 +115,7 @@
 		);
 		/* TODO: also output device column, e.g. "/dev/sdX" */
 
-		xchdir("..");
+		xchdir(scsi_dir);
 	}
 
 	if (ENABLE_FEATURE_CLEAN_UP)

[Attachment #11 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html \
charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: \
space; -webkit-line-break: after-white-space;"><div><br><div> <div style="color: \
rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: \
0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space;">//Markus - The panama-hat hacker</div>

</div>
<br></div></body></html>


["signature.asc" (signature.asc)]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.30

iQIVAwUBWeuCHrc8vHcI+owQAQhI4hAAlC0sca9L0+/40SO6UOmx3lXUwDtOBDzA
fvHZJsqgKBeXrDQbgnnOlc3oNFqslmBOz1ZfdpFEE+AugbtcG4uD2vHzg/rWu8J3
2Z9+QOHK8aCjQZQGF782pked5+jqUaYQcNvCBrZuuaDT2pnVjBsiXO2wSmWuEJIM
sogBj+fEvEvLrLqZfZBx5m9oJTlffZ3RX9uVMh2mLhCQxKsZfAeRavjYb/il3qOl
PvRusZ3oaogCRweNfrK6J00Wz8wMQjpsiFCU2jWtAPNLaBA+iQ63FJslBzOwukka
823iMD6CGO37IyjWY+n2bxJNNzZxz1BNbfhQ0x/VqIO43R89QzAOTUn2SZtjqBsc
MlcQGraG8c+vSI8i4J3THbtRBxhhnoL9RDadS2wbX7gpVm7iYG/LmRoFP8422+Tw
sztw7vzBDETuJJWlpKrLwdywDCQb4/mw8pKwPxI8SjCVwDrQbrEL5wTy1jasrPvN
mVhXcgylGGXmP5YMrnO5U0ldzgIFlahWpC08nDMK9Ff70I6fpRqRGsDhij6VOb7Z
uPDiUVknpy9y2YBLaTU4McB0Go+XOcwW4zfR5pkPYLDyeuF5XsHdJ23ErllGmFfN
DrjKe8k4y/IKHhQi7pkB6pwMTJPz9EGn6reErDj+TJJh5IayGvY/cgr0jdVv+2kP
awjNIkwVc2A=
=Kt1Z
-----END PGP SIGNATURE-----


_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic