FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Red Hat Linux

 
 
LinkBack Thread Tools
 
Old 09-09-2011, 02:25 PM
Ales Kozumplik
 
Default Shorten long NIC descriptions to 60.

Else it doesn't fit on the 80 chars wide terminal and the user can't see
them anyway. Especially the InfiniBand devices tend to be called long
names.

Related: rhbz#660684
---
loader2/net.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/loader2/net.c b/loader2/net.c
index ee63154..dc84983 100644
--- a/loader2/net.c
+++ b/loader2/net.c
@@ -2184,6 +2184,8 @@ int chooseNetworkInterface(struct loaderData_s * loaderData) {
char **devices;
char **deviceNames;
char *ksMacAddr = NULL, *seconds = strdup("10"), *idstr = NULL;
+ const unsigned MAX_DESC = 60;
+ char desc[MAX_DESC];
struct device **devs;
struct newtWinEntry entry[] = {{_("Seconds:"), (const char **) &seconds, 0},
{NULL, NULL, 0 }};
@@ -2212,10 +2214,17 @@ int chooseNetworkInterface(struct loaderData_s * loaderData) {
if (!devs[i]->device)
continue;
if (devs[i]->desc) {
+ if (strlen(devs[i]->desc) < MAX_DESC) {
+ strcpy(desc, devs[i]->desc);
+ } else {
+ strncpy(desc, devs[i]->desc, MAX_DESC);
+ desc[MAX_DESC - 4] = '';
+ strcat(desc, "...");
+ }
deviceNames[deviceNums] = alloca(strlen(devs[i]->device) +
- strlen(devs[i]->desc) + 4);
+ strlen(desc) + 4);
sprintf(deviceNames[deviceNums],"%s - %s",
- devs[i]->device, devs[i]->desc);
+ devs[i]->device, desc);
if (strlen(deviceNames[deviceNums]) > max)
max = strlen(deviceNames[deviceNums]);
devices[deviceNums++] = devs[i]->device;
--
1.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 09-12-2011, 02:25 PM
Chris Lumens
 
Default Shorten long NIC descriptions to 60.

> @@ -2212,10 +2214,17 @@ int chooseNetworkInterface(struct loaderData_s * loaderData) {
> if (!devs[i]->device)
> continue;
> if (devs[i]->desc) {
> + if (strlen(devs[i]->desc) < MAX_DESC) {
> + strcpy(desc, devs[i]->desc);
> + } else {
> + strncpy(desc, devs[i]->desc, MAX_DESC);
> + desc[MAX_DESC - 4] = '';
> + strcat(desc, "...");
> + }
> deviceNames[deviceNums] = alloca(strlen(devs[i]->device) +
> - strlen(devs[i]->desc) + 4);
> + strlen(desc) + 4);
> sprintf(deviceNames[deviceNums],"%s - %s",
> - devs[i]->device, devs[i]->desc);
> + devs[i]->device, desc);
> if (strlen(deviceNames[deviceNums]) > max)
> max = strlen(deviceNames[deviceNums]);
> devices[deviceNums++] = devs[i]->device;

I'm a little concerned here that the most useful identifying information
will end up at the end of the description, therefore chopped off.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 09-13-2011, 06:22 AM
Ales Kozumplik
 
Default Shorten long NIC descriptions to 60.

On 09/12/2011 04:25 PM, Chris Lumens wrote:

I'm a little concerned here that the most useful identifying information
will end up at the end of the description, therefore chopped off.

- Chris


I checked and that is not the case, for regular cards:

Ethernet controller: Broadcom Corporation NetXtreme BCM5721 Gigabit
Ethernet PCI Express (rev 11)


For infiniband:

InfiniBand: Mellanox Technologies MT25418 [ConnectX VPI PCIe 2.0 2.5GT/s
- IB DDR / 10GigE] (rev a0)


So the final 20 characters or so is stuff like bus type and revision
whereas the beginning is the card manufacturer and type, but of course
there's no guarantee of that for all the devices. My reasoning was that
it would in any case be better to to trim part of the description string
over having the interface identifier (eth0, ib0 etc.) out of the screen.


Alternative is to drop this patch and wait for someone to start
complaining, which is fine by me.


Ales

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 09-15-2011, 07:32 PM
Chris Lumens
 
Default Shorten long NIC descriptions to 60.

> I checked and that is not the case, for regular cards:
>
> Ethernet controller: Broadcom Corporation NetXtreme BCM5721 Gigabit
> Ethernet PCI Express (rev 11)
>
> For infiniband:
>
> InfiniBand: Mellanox Technologies MT25418 [ConnectX VPI PCIe 2.0
> 2.5GT/s - IB DDR / 10GigE] (rev a0)

My concern was that MAC addresses or port numbers would be appearing at
the end of the string. That not being the case, ACK.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 08:21 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org