From 59796edcf21c7c19d58a223001f9ed13746c51c2 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Thu, 10 Sep 2015 10:17:59 +0300 Subject: mei: make modules.alias UUID information easier to read scripts/mod/file2alias.c:add_uuid() convert UUID into a single string which does not conform to the standard little endian UUID formatting. This patch changes add_uuid() to output same format as %pUL and modifies the mei driver to match the change. Signed-off-by: Prarit Bhargava Signed-off-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- scripts/mod/file2alias.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 5f2088209132..fa79d113f34c 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -137,10 +137,12 @@ static inline void add_wildcard(char *str) static inline void add_uuid(char *str, uuid_le uuid) { int len = strlen(str); - int i; - for (i = 0; i < 16; i++) - sprintf(str + len + (i << 1), "%02x", uuid.b[i]); + sprintf(str + len, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + uuid.b[3], uuid.b[2], uuid.b[1], uuid.b[0], + uuid.b[5], uuid.b[4], uuid.b[7], uuid.b[6], + uuid.b[8], uuid.b[9], uuid.b[10], uuid.b[11], + uuid.b[12], uuid.b[13], uuid.b[14], uuid.b[15]); } /** -- cgit v1.2.3 From b26864cad1c9f66f4966726ba7bc81d2b9b8f990 Mon Sep 17 00:00:00 2001 From: Tomas Winkler Date: Thu, 10 Sep 2015 10:18:01 +0300 Subject: mei: bus: add client protocol version to the device alias The device alias now looks like mei:S:uuid:N:* In that way we can bind different drivers to clients with different protocol versions if required. Signed-off-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/misc/mei/bus.c | 28 +++++++++++++++++++++------- drivers/nfc/microread/mei.c | 2 +- drivers/nfc/pn544/mei.c | 2 +- include/linux/mod_devicetable.h | 3 +++ scripts/mod/devicetable-offsets.c | 1 + scripts/mod/file2alias.c | 4 +++- 6 files changed, 30 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index d92017fa1630..38bc4380ad08 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c @@ -453,17 +453,26 @@ struct mei_cl_device_id *mei_cl_device_find(struct mei_cl_device *cldev, { const struct mei_cl_device_id *id; const uuid_le *uuid; + u8 version; + bool match; uuid = mei_me_cl_uuid(cldev->me_cl); + version = mei_me_cl_ver(cldev->me_cl); id = cldrv->id_table; while (uuid_le_cmp(NULL_UUID_LE, id->uuid)) { if (!uuid_le_cmp(*uuid, id->uuid)) { + match = true; - if (!cldev->name[0]) - return id; + if (cldev->name[0]) + if (strncmp(cldev->name, id->name, + sizeof(id->name))) + match = false; - if (!strncmp(cldev->name, id->name, sizeof(id->name))) + if (id->version != MEI_CL_VERSION_ANY) + if (id->version != version) + match = false; + if (match) return id; } @@ -647,7 +656,8 @@ static int mei_cl_device_uevent(struct device *dev, struct kobj_uevent_env *env) if (add_uevent_var(env, "MEI_CL_NAME=%s", cldev->name)) return -ENOMEM; - if (add_uevent_var(env, "MODALIAS=mei:%s:%pUl:", cldev->name, uuid)) + if (add_uevent_var(env, "MODALIAS=mei:%s:%pUl:%02X:", + cldev->name, uuid, version)) return -ENOMEM; return 0; @@ -737,8 +747,10 @@ static bool mei_cl_dev_setup(struct mei_device *bus, mei_cl_dev_fixup(cldev); if (cldev->do_match) - dev_set_name(&cldev->dev, "mei:%s:%pUl", - cldev->name, mei_me_cl_uuid(cldev->me_cl)); + dev_set_name(&cldev->dev, "mei:%s:%pUl:%02X", + cldev->name, + mei_me_cl_uuid(cldev->me_cl), + mei_me_cl_ver(cldev->me_cl)); return cldev->do_match == 1; } @@ -754,7 +766,9 @@ static int mei_cl_bus_dev_add(struct mei_cl_device *cldev) { int ret; - dev_dbg(cldev->bus->dev, "adding %pUL\n", mei_me_cl_uuid(cldev->me_cl)); + dev_dbg(cldev->bus->dev, "adding %pUL:%02X\n", + mei_me_cl_uuid(cldev->me_cl), + mei_me_cl_ver(cldev->me_cl)); ret = device_add(&cldev->dev); if (!ret) cldev->is_added = 1; diff --git a/drivers/nfc/microread/mei.c b/drivers/nfc/microread/mei.c index f9f5fc97cdd7..93328bd45110 100644 --- a/drivers/nfc/microread/mei.c +++ b/drivers/nfc/microread/mei.c @@ -67,7 +67,7 @@ static int microread_mei_remove(struct mei_cl_device *device) } static struct mei_cl_device_id microread_mei_tbl[] = { - { MICROREAD_DRIVER_NAME, MEI_NFC_UUID}, + { MICROREAD_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY}, /* required last entry */ { } diff --git a/drivers/nfc/pn544/mei.c b/drivers/nfc/pn544/mei.c index 101a37e12efa..80f897b4a401 100644 --- a/drivers/nfc/pn544/mei.c +++ b/drivers/nfc/pn544/mei.c @@ -67,7 +67,7 @@ static int pn544_mei_remove(struct mei_cl_device *device) } static struct mei_cl_device_id pn544_mei_tbl[] = { - { PN544_DRIVER_NAME, MEI_NFC_UUID}, + { PN544_DRIVER_NAME, MEI_NFC_UUID, MEI_CL_VERSION_ANY}, /* required last entry */ { } diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 5e8a0ad22cbc..6975cbf1435b 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -601,11 +601,13 @@ struct ipack_device_id { #define MEI_CL_MODULE_PREFIX "mei:" #define MEI_CL_NAME_SIZE 32 +#define MEI_CL_VERSION_ANY 0xff /** * struct mei_cl_device_id - MEI client device identifier * @name: helper name * @uuid: client uuid + * @version: client protocol version * @driver_info: information used by the driver. * * identifies mei client device by uuid and name @@ -613,6 +615,7 @@ struct ipack_device_id { struct mei_cl_device_id { char name[MEI_CL_NAME_SIZE]; uuid_le uuid; + __u8 version; kernel_ulong_t driver_info; }; diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index e70fcd12eeeb..5a6edacc85d9 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -185,6 +185,7 @@ int main(void) DEVID(mei_cl_device_id); DEVID_FIELD(mei_cl_device_id, name); DEVID_FIELD(mei_cl_device_id, uuid); + DEVID_FIELD(mei_cl_device_id, version); DEVID(rio_device_id); DEVID_FIELD(rio_device_id, did); diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index fa79d113f34c..9bc2cfe0ee37 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1202,16 +1202,18 @@ static int do_cpu_entry(const char *filename, void *symval, char *alias) } ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry); -/* Looks like: mei:S:uuid */ +/* Looks like: mei:S:uuid:N:* */ static int do_mei_entry(const char *filename, void *symval, char *alias) { DEF_FIELD_ADDR(symval, mei_cl_device_id, name); DEF_FIELD_ADDR(symval, mei_cl_device_id, uuid); + DEF_FIELD(symval, mei_cl_device_id, version); sprintf(alias, MEI_CL_MODULE_PREFIX); sprintf(alias + strlen(alias), "%s:", (*name)[0] ? *name : "*"); add_uuid(alias, *uuid); + ADD(alias, ":", version != MEI_CL_VERSION_ANY, version); strcat(alias, ":*"); -- cgit v1.2.3 From 235024e519fa16242f916ec41b00547582f561a7 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:41 +0300 Subject: ver_linux: gcc -dumpversion, use regex to find version number Rely on regex to find the version number, rather than a field number. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 7de36df4eaa5..af6467e4859a 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -11,8 +11,12 @@ echo ' ' uname -a echo ' ' -gcc -dumpversion 2>&1| awk \ -'NR==1{print "Gnu C ", $1}' +gcc -dumpversion 2>&1 | +awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("GNU C\t\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' make --version 2>&1 | awk -F, '{print $1}' | awk \ '/GNU Make/{print "Gnu make ",$NF}' -- cgit v1.2.3 From 1d60b873aecc6fce4893b76500c30374f8c9e394 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:42 +0300 Subject: ver_linux: make --version, use regex to find version number Rely on regex to find the version number, rather than a field number. Reduce the number of 'awk' invocations from two to one. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index af6467e4859a..31c0e4d09ffc 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -18,8 +18,12 @@ awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ substr($0,RSTART,RLENGTH)) }' -make --version 2>&1 | awk -F, '{print $1}' | awk \ - '/GNU Make/{print "Gnu make ",$NF}' +make --version 2>&1 | +awk '/GNU Make/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("GNU Make\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' echo "binutils $(ld -v | egrep -o '[0-9]+\.[0-9\.]+')" -- cgit v1.2.3 From 3e2f5cfb38dbd7d0c4a9cfd5093bea4b027a9d6d Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:43 +0300 Subject: ver_linux: binutils, fix inaccurate output Current implementation output on Gentoo Linux: binutils 2.25.1 1.1 2.25.1 Proposed implementation: Binutils 2.25.1 Tested on: Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Rely on regex to find the version number. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 31c0e4d09ffc..1fea7494a1b1 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -25,7 +25,12 @@ awk '/GNU Make/{ substr($0,RSTART,RLENGTH)) }' -echo "binutils $(ld -v | egrep -o '[0-9]+\.[0-9\.]+')" +ld -v 2>&1 | +awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Binutils\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' echo -n "util-linux " fdformat --version | awk '{print $NF}' | sed -e s/^util-linux-// -e s/\)$// -- cgit v1.2.3 From 12b2732c825c9ff59fa74fe9df50264d8275c14f Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:44 +0300 Subject: ver_linux: util-linux, 'fdformat' not ubiquitous any longer The current implementation relies on 'fdformat' to output the version of 'util-linux'. This does not seem to be reliable any longer, as 'fdformat' does not seem to come preinstalled in all ditros these days. The proposed implementation uses 'mount' to output both the version of 'util-linux' and 'mount' proper, as 'mount' is also a part of the 'util-linux' package. Tested on: Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Rely on regex to find the version number, rather than a field number. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 1fea7494a1b1..28e76400d133 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -32,11 +32,12 @@ awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ substr($0,RSTART,RLENGTH)) }' -echo -n "util-linux " -fdformat --version | awk '{print $NF}' | sed -e s/^util-linux-// -e s/\)$// - -echo -n "mount " -mount --version | awk '{print $NF}' | sed -e s/^mount-// -e s/\)$// +mount --version 2>&1 | +awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + $0 = substr($0,RSTART,RLENGTH) + printf("Util-linux\t\t%s\nMount\t\t\t%s\n",$0,$0) +}' depmod -V 2>&1 | awk 'NR==1 {print "module-init-tools ",$NF}' -- cgit v1.2.3 From 5bcb2f59240cb5501956f2a089ba82e0b8621564 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:45 +0300 Subject: ver_linux: module-init-tools, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Tested on: Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 28e76400d133..7cc74d15e7f1 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -39,7 +39,12 @@ awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ printf("Util-linux\t\t%s\nMount\t\t\t%s\n",$0,$0) }' -depmod -V 2>&1 | awk 'NR==1 {print "module-init-tools ",$NF}' +depmod -V 2>&1 | +awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Module-init-tools\t%s\n", + substr($0,RSTART,RLENGTH)) +}' tune2fs 2>&1 | grep "^tune2fs" | sed 's/,//' | awk \ 'NR==1 {print "e2fsprogs ", $2}' -- cgit v1.2.3 From a8782227598084d95358c08a6d3d6ea84422af11 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:46 +0300 Subject: ver_linux: e2fsprogs, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'sed' + 'awk'. Tested on: Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 7cc74d15e7f1..2e1929f2c9de 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -46,8 +46,12 @@ awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ substr($0,RSTART,RLENGTH)) }' -tune2fs 2>&1 | grep "^tune2fs" | sed 's/,//' | awk \ -'NR==1 {print "e2fsprogs ", $2}' +tune2fs 2>&1 | +awk '/^tune2fs/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("E2fsprogs\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' fsck.jfs -V 2>&1 | grep version | sed 's/,//' | awk \ 'NR==1 {print "jfsutils ", $3}' -- cgit v1.2.3 From 0fc8de5638e8668df65a4cbeb4ee3e4319b6eaec Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:47 +0300 Subject: ver_linux: jfsutils, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'sed' + 'awk'. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 2e1929f2c9de..7d85447d2ba5 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -53,8 +53,12 @@ awk '/^tune2fs/{ substr($0,RSTART,RLENGTH)) }' -fsck.jfs -V 2>&1 | grep version | sed 's/,//' | awk \ -'NR==1 {print "jfsutils ", $3}' +fsck.jfs -V 2>&1 | +awk '/version/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Jfsutils\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' reiserfsck -V 2>&1 | grep ^reiserfsck | awk \ 'NR==1{print "reiserfsprogs ", $2}' -- cgit v1.2.3 From 63e781ad2442054b9d7b41a949c026ec7c16aafe Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:48 +0300 Subject: ver_linux: reiserfsprogs, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 7d85447d2ba5..65d4c0230712 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -60,8 +60,12 @@ awk '/version/{ substr($0,RSTART,RLENGTH)) }' -reiserfsck -V 2>&1 | grep ^reiserfsck | awk \ -'NR==1{print "reiserfsprogs ", $2}' +reiserfsck -V 2>&1 | +awk '/^reiserfsck/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Reiserfsprogs\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' fsck.reiser4 -V 2>&1 | grep ^fsck.reiser4 | awk \ 'NR==1{print "reiser4progs ", $2}' -- cgit v1.2.3 From 44422f3cd9d2d28049b8eb544ebbc845fd419eef Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:49 +0300 Subject: ver_linux: xfsprogs, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 65d4c0230712..a926225e10af 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -70,8 +70,12 @@ awk '/^reiserfsck/{ fsck.reiser4 -V 2>&1 | grep ^fsck.reiser4 | awk \ 'NR==1{print "reiser4progs ", $2}' -xfs_db -V 2>&1 | grep version | awk \ -'NR==1{print "xfsprogs ", $3}' +xfs_db -V 2>&1 | +awk '/version/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Xfsprogs\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' pccardctl -V 2>&1| grep pcmciautils | awk '{print "pcmciautils ", $2}' -- cgit v1.2.3 From f437d1ed68d3a51728c0ba3e7fb39a03df74fd1b Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:50 +0300 Subject: ver_linux: pcmciautils, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index a926225e10af..e36cceb45b0c 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -77,7 +77,12 @@ awk '/version/{ substr($0,RSTART,RLENGTH)) }' -pccardctl -V 2>&1| grep pcmciautils | awk '{print "pcmciautils ", $2}' +pccardctl -V 2>&1 | +awk '/pcmciautils/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Pcmciautils\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' cardmgr -V 2>&1| grep version | awk \ 'NR==1{print "pcmcia-cs ", $3}' -- cgit v1.2.3 From 8fb0959822e16a91c23cb41e53693180a2b3389f Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:51 +0300 Subject: ver_linux: quota-tools, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index e36cceb45b0c..d5b342eadca0 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -87,8 +87,12 @@ awk '/pcmciautils/{ cardmgr -V 2>&1| grep version | awk \ 'NR==1{print "pcmcia-cs ", $3}' -quota -V 2>&1 | grep version | awk \ -'NR==1{print "quota-tools ", $NF}' +quota -V 2>&1 | +awk '/version/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Quota-tools\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' pppd --version 2>&1| grep version | awk \ 'NR==1{print "PPP ", $3}' -- cgit v1.2.3 From b903fa982db2832d7f402ff00cf30145e8a7fca0 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:52 +0300 Subject: ver_linux: ppp, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'. Tested on: Oracle Linux Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index d5b342eadca0..af5ac824e483 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -94,8 +94,12 @@ awk '/version/{ substr($0,RSTART,RLENGTH)) }' -pppd --version 2>&1| grep version | awk \ -'NR==1{print "PPP ", $3}' +pppd --version 2>&1 | +awk '/version/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("PPP\t\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' isdnctrl 2>&1 | grep version | awk \ 'NR==1{print "isdn4k-utils ", $NF}' -- cgit v1.2.3 From cbb57d10af048d886274129d91f2347d4d48e489 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:53 +0300 Subject: ver_linux: libc, input redirection to sed fails in some distros The current implementation has been found not to work across all distros. The proposed implementation relies on 'sed' to both output the string 'Linux C Library' as well as to open '/proc/self/maps' without having to use output redirection. Tested on: Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Arch Linux openSuSE 13.2 Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index af5ac824e483..909d039284f8 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -107,8 +107,12 @@ isdnctrl 2>&1 | grep version | awk \ showmount --version 2>&1 | grep nfs-utils | awk \ 'NR==1{print "nfs-utils ", $NF}' -echo -n "Linux C Library " -sed -n -e '/^.*\/libc-\([^/]*\)\.so$/{s//\1/;p;q}' < /proc/self/maps +test -r /proc/self/maps && +sed ' + /.*libc-\(.*\)\.so$/!d + s//Linux C Library\t\t\1/ + q +' /proc/self/maps ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \ 'NR==1{print "Dynamic linker (ldd) ", $NF}' -- cgit v1.2.3 From 1e5f739c61f669fdd954b1f16674c07bdf5ef8a1 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:54 +0300 Subject: ver_linux: ldd, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'head' + 'awk'. The '-v' flag either seems to have been deprecated in some distros, e.g. Gentoo, or is an alias for '--version' in others. The proposed implementation uses the latter flag only. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 909d039284f8..a7d0ecad5ad4 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -114,8 +114,12 @@ sed ' q ' /proc/self/maps -ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \ -'NR==1{print "Dynamic linker (ldd) ", $NF}' +ldd --version 2>&1 | +awk '/^ldd/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Dynamic linker (ldd)\t%s\n", + substr($0,RSTART,RLENGTH)) +}' ls -l /usr/lib/libg++.so /usr/lib/libstdc++.so 2>/dev/null | awk -F. \ '{print "Linux C++ Library " $4"."$5"."$6}' -- cgit v1.2.3 From 53494ba9dac543ffce5bc717556b111ca8c44b7e Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:55 +0300 Subject: ver_linux: libcpp, fix missing output Neither 'libg++.so', nor 'libstdc++.so' were found where the current implementation expects them to be found in the distros below. Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Which results in zero ouput generated. The proposed implementation relies on 'ldconfig' to locate the libraries in question. 'Sed' is used to do the text processing. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index a7d0ecad5ad4..882ddb961b49 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -121,9 +121,18 @@ awk '/^ldd/{ substr($0,RSTART,RLENGTH)) }' -ls -l /usr/lib/libg++.so /usr/lib/libstdc++.so 2>/dev/null | awk -F. \ - '{print "Linux C++ Library " $4"."$5"."$6}' - +libcpp=`ldconfig -p 2>/dev/null | + awk '/(libg|stdc)[+]+\.so/ { + print $NF + exit + } +'` +test -r "$libcpp" && +ls -l $libcpp | +sed ' + s!.*so\.!! + s!^!Linux C++ Library\t! +' ps --version 2>&1 | grep version | awk \ 'NR==1{print "Procps ", $NF}' -- cgit v1.2.3 From e7230872ce44667003876f6ef6d3401636033453 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:56 +0300 Subject: ver_linux: procps, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 882ddb961b49..2269803dddb5 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -133,8 +133,12 @@ sed ' s!.*so\.!! s!^!Linux C++ Library\t! ' -ps --version 2>&1 | grep version | awk \ -'NR==1{print "Procps ", $NF}' +ps --version 2>&1 | +awk '/version/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Procps\t\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' ifconfig --version 2>&1 | grep tools | awk \ 'NR==1{print "Net-tools ", $NF}' -- cgit v1.2.3 From be6bb51a9f6a60995e0069bfdd9e0611d78ae4c6 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:57 +0300 Subject: ver_linux: net-tools, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 2269803dddb5..4ef1b7d370a9 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -140,8 +140,12 @@ awk '/version/{ substr($0,RSTART,RLENGTH)) }' -ifconfig --version 2>&1 | grep tools | awk \ -'NR==1{print "Net-tools ", $NF}' +ifconfig --version 2>&1 | +awk '/tools/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Net-tools\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' # Kbd needs 'loadkeys -h', loadkeys -h 2>&1 | awk \ -- cgit v1.2.3 From 7a343234ed967de0c59cdbbf5629e6d762259549 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:58 +0300 Subject: ver_linux: loadkeys, look for numerical input, not field number 'loadkeys -h' no longer prints the version number across all distros, despite the claim to do so in the manpage, which I found to be the case on a Debian Linux system. The proposed implementation utilises the output of 'loadkeys -V' to acquire the version of both 'Kbd' and 'Console-tools'. Tested on: Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 4ef1b7d370a9..e6b57d57df98 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -147,13 +147,12 @@ awk '/tools/{ substr($0,RSTART,RLENGTH)) }' -# Kbd needs 'loadkeys -h', -loadkeys -h 2>&1 | awk \ -'(NR==1 && ($3 !~ /option/)) {print "Kbd ", $3}' - -# while console-tools needs 'loadkeys -V'. -loadkeys -V 2>&1 | awk \ -'(NR==1 && ($2 ~ /console-tools/)) {print "Console-tools ", $3}' +loadkeys -V 2>&1 | +awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + $0 = substr($0,RSTART,RLENGTH) + printf("Kbd\t\t\t%s\nConsole-tools\t\t%s\n",$0,$0) +}' oprofiled --version 2>&1 | awk \ '(NR==1 && ($2 == "oprofile")) {print "oprofile ", $3}' -- cgit v1.2.3 From 29dfecff10f3e1c8b4e2c7e390434d4932c4542f Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:39:59 +0300 Subject: ver_linux: sh-utils, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Tested on: Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index e6b57d57df98..1c6ec2244ae8 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -157,7 +157,12 @@ awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ oprofiled --version 2>&1 | awk \ '(NR==1 && ($2 == "oprofile")) {print "oprofile ", $3}' -expr --v 2>&1 | awk 'NR==1{print "Sh-utils ", $NF}' +expr --v 2>&1 | +awk '/^expr/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Sh-utils\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' udevinfo -V 2>&1 | grep version | awk '{print "udev ", $3}' -- cgit v1.2.3 From 1245b7ec0f8cb223a252c71ed39c33c005c0631c Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:40:00 +0300 Subject: ver_linux: use 'udevadm', instead of 'udevinfo' 'udevinfo' no longer seems to be available across various distros. 'udevadm' seems to be the currently valid way to look up the 'udev' version. Tested on: Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Proposed implementation also eliminates the necessity to invoke 'grep' + 'awk'. Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 1c6ec2244ae8..f839be33bcb4 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -164,7 +164,12 @@ awk '/^expr/{ substr($0,RSTART,RLENGTH)) }' -udevinfo -V 2>&1 | grep version | awk '{print "udev ", $3}' +udevadm --version 2>&1 | +awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Udev\t\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' iwconfig --version 2>&1 | awk \ '(NR==1 && ($3 == "version")) {print "wireless-tools ",$4}' -- cgit v1.2.3 From 031c155a8c41edee6fad92dc4eee4c5fe2a06dea Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:40:01 +0300 Subject: ver_linux: wireless-tools, look for numerical input, not field number Rely on regex to find the version number, rather than rely on numerical input to be found in a particular input field. Tested on: Gentoo Linux Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index f839be33bcb4..ae426c2e6f2a 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -171,8 +171,12 @@ awk '/[0-9]+([.]?[0-9]+)+/ && !/not found$/{ substr($0,RSTART,RLENGTH)) }' -iwconfig --version 2>&1 | awk \ -'(NR==1 && ($3 == "version")) {print "wireless-tools ",$4}' +iwconfig --version 2>&1 | +awk '/version/{ + match($0, /[0-9]+([.]?[0-9]+)+/) + printf("Wireless-tools\t\t%s\n", + substr($0,RSTART,RLENGTH)) +}' if [ -e /proc/modules ]; then X=`cat /proc/modules | sed -e "s/ .*$//"` -- cgit v1.2.3 From 1920c298e74b1b9982247bcc33f2a206271ec835 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Mon, 12 Oct 2015 21:40:02 +0300 Subject: ver_linux: proc/modules, limit text processing to 'sed' This patch is more of a personal preference, rather than a fix for a problem. The current implementation used a combination of both 'cat' and 'sed' to generate an unsorted list of kernel modules separated by while space. The proposed implementation uses 'sort' and 'sed' to generate a sort list of kernel modules separated by while space. Tested on: Gentoo Linux Debian 6.0.10 Oracle Linux Server release 7.1 Arch Linux openSuSE 13.2 Signed-off-by: Alexander Kapshuk Signed-off-by: Greg Kroah-Hartman --- scripts/ver_linux | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index ae426c2e6f2a..024a11ac8b97 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -178,7 +178,16 @@ awk '/version/{ substr($0,RSTART,RLENGTH)) }' -if [ -e /proc/modules ]; then - X=`cat /proc/modules | sed -e "s/ .*$//"` - echo "Modules Loaded "$X -fi +test -e /proc/modules && +sort /proc/modules | +sed ' + s/ .*// + H +${ + g + s/^\n/Modules Loaded\t\t/ + y/\n/ / + q +} + d +' -- cgit v1.2.3