[PATCH v2 1/1] lsscsi: Fix xchdir(".."); from symlink in /sys/bus/scsi/devices

Denys Vlasenko vda.linux at googlemail.com
Sun Oct 22 08:44:14 UTC 2017


Applied, thanks!

On Sat, Oct 21, 2017 at 9:34 PM, Markus Gothe <nietzsche at lysator.liu.se> wrote:
> 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
>
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list