From ae828e5caa68a64b7bf4f2f01ab5a559aff1d9df Mon Sep 17 00:00:00 2001 From: uvok cheetah Date: Sun, 15 Sep 2024 11:33:35 +0200 Subject: busybox,lsusb: Switch to one-line output --- .../0010-lsusb-show-goddamn-descriptors.patch | 34 ++++++++++------------ 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'patches/busybox/0010-lsusb-show-goddamn-descriptors.patch') diff --git a/patches/busybox/0010-lsusb-show-goddamn-descriptors.patch b/patches/busybox/0010-lsusb-show-goddamn-descriptors.patch index e937991..9ecbf16 100644 --- a/patches/busybox/0010-lsusb-show-goddamn-descriptors.patch +++ b/patches/busybox/0010-lsusb-show-goddamn-descriptors.patch @@ -16,30 +16,30 @@ Index: busybox-1.36.1/util-linux/lsusb.c parser = config_open2(uevent_filename, fopen_for_read); free(uevent_filename); -@@ -58,10 +62,39 @@ static int FAST_FUNC fileAction(struct r +@@ -58,10 +62,34 @@ static int FAST_FUNC fileAction(struct r continue; } } + + { -+ struct stat manu_stat; -+ int manu_ret = stat(manu_filename, &manu_stat); -+ if (manu_ret == 0 && manu_stat.st_size != 0) -+ { -+ FILE* manu_file = fopen(manu_filename, "r"); -+ fread(manu_buf, 1, MIN(manu_stat.st_size, sizeof(manu_buf)), manu_file); ++ FILE *manu_file = fopen(manu_filename, "r"); ++ if (manu_file != NULL) { ++ // leave one for terminator ++ size_t read = fread(manu_buf, 1, sizeof(manu_buf) - 1, manu_file); + fclose(manu_file); ++ // remove newline ++ read && (manu_buf[read - 1] = '\0'); + manu_buf[sizeof(manu_buf) - 1] = '\0'; + } + } + { -+ struct stat product_stat; -+ int product_ret = stat(product_filename, &product_stat); -+ if (product_ret == 0 && product_stat.st_size != 0) -+ { -+ FILE* product_file = fopen(product_filename, "r"); -+ fread(product_buf, 1, MIN(product_stat.st_size, sizeof(product_buf)), product_file); ++ FILE *product_file = fopen(product_filename, "r"); ++ if (product_file != NULL) { ++ // leave one for terminator ++ size_t read = fread(product_buf, 1, sizeof(product_buf) - 1, product_file); + fclose(product_file); ++ // remove newline ++ read && (product_buf[read - 1] = '\0'); + product_buf[sizeof(product_buf) - 1] = '\0'; + } + } @@ -47,12 +47,8 @@ Index: busybox-1.36.1/util-linux/lsusb.c config_close(parser); if (busnum) { - printf("Bus %s Device %s: ID %04x:%04x\n", busnum, devnum, product_vid, product_did); -+ // These already include the newline? -+ if (*manu_buf) -+ printf("\tManufacturer: %s", manu_buf); -+ if (*product_buf) -+ printf("\tProduct: %s", product_buf); +- printf("Bus %s Device %s: ID %04x:%04x\n", busnum, devnum, product_vid, product_did); ++ printf("Bus %s Device %s: ID %04x:%04x %s %s\n", busnum, devnum, product_vid, product_did, manu_buf, product_buf); free(busnum); free(devnum); } -- cgit v1.2.3