[PATCH v2 1/1] lsscsi: Fix xchdir(".."); from symlink in /sys/bus/scsi/devices
Markus Gothe
nietzsche at lysator.liu.se
Sat Oct 21 19:34:22 UTC 2017
Did a patch via git format-patch command:
Signed-off-by: Markus Gothe <nietzsche at lysator.liu.se>
---
miscutils/lsscsi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/miscutils/lsscsi.c b/miscutils/lsscsi.c
index d7cd510..8272ab5 100644
--- a/miscutils/lsscsi.c
+++ b/miscutils/lsscsi.c
@@ -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;
@@ -53,7 +55,7 @@ int lsscsi_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
struct dirent *de;
DIR *dir;
- xchdir("/sys/bus/scsi/devices");
+ xchdir(scsi_dir);
dir = xopendir(".");
while ((de = readdir(dir)) != NULL) {
@@ -112,7 +114,7 @@ int lsscsi_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
);
/* TODO: also output device column, e.g. "/dev/sdX" */
- xchdir("..");
+ xchdir(scsi_dir);
}
if (ENABLE_FEATURE_CLEAN_UP)
--
1.9.5 (Apple Git-50.3)
On 21 Oct 2017, at 19:21 , Markus Gothe <nietzsche at lysator.liu.se> wrote:
> 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
> <lsscsi.patch>
>
> //Markus - The panama-hat hacker
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
//Markus - The panama-hat hacker
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20171021/5d4f26ec/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 824 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20171021/5d4f26ec/attachment.asc>
More information about the busybox
mailing list