[Iprdd-commit] iprutils iprconfig.c, 1.140, 1.141 iprlib.c, 1.126, 1.127 version.mk, 1.76, 1.77
Brought to you by:
brking
|
From: Kleber S. de S. <kl...@us...> - 2009-10-30 18:46:49
|
Update of /cvsroot/iprdd/iprutils In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv19014/iprutils Modified Files: iprconfig.c iprlib.c version.mk Log Message: Change default write buffer mode. Fix show-details for ses devices. Comment out get_write_buffer_dev. Fix Platform Location information. Fix iprconfig indentation. Index: version.mk =================================================================== RCS file: /cvsroot/iprdd/iprutils/version.mk,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- version.mk 16 Sep 2009 23:38:05 -0000 1.76 +++ version.mk 30 Oct 2009 18:46:39 -0000 1.77 @@ -6,9 +6,9 @@ IPR_MAJOR_RELEASE=2 IPR_MINOR_RELEASE=2 -IPR_FIX_LEVEL=17 +IPR_FIX_LEVEL=18 IPR_RELEASE=1 -IPR_FIX_DATE=(September 16, 2009) +IPR_FIX_DATE=(October 30, 2009) IPR_VERSION_STR=$(IPR_MAJOR_RELEASE).$(IPR_MINOR_RELEASE).$(IPR_FIX_LEVEL) $(IPR_FIX_DATE) Index: iprlib.c =================================================================== RCS file: /cvsroot/iprdd/iprutils/iprlib.c,v retrieving revision 1.126 retrieving revision 1.127 diff -u -d -r1.126 -r1.127 --- iprlib.c 16 Sep 2009 23:38:05 -0000 1.126 +++ iprlib.c 30 Oct 2009 18:46:39 -0000 1.127 @@ -32,7 +32,7 @@ int ipr_sg_required = 0; int polling_mode = 0; int ipr_fast = 0; -static int ipr_mode5_write_buffer = 1; +static int ipr_mode5_write_buffer = 0; struct sysfs_dev *head_zdev = NULL; struct sysfs_dev *tail_zdev = NULL; @@ -1699,15 +1699,22 @@ return 0; } +static int ipr_select_pci_address(const struct dirent *dirent) +{ + if (strstr(dirent->d_name, "address")) + return 1; + return 0; +} + /** - * read_slot_attr - + * read_attr_file - * @path: path name of device/file to open * @out: character array * * Returns: * 0 if success / non-zero on failure **/ -static int read_slot_attr(char *path, char out[SYSFS_PATH_MAX]) +static int read_attr_file(char *path, char *out, int size) { int fd, len; @@ -1716,7 +1723,7 @@ return -EIO; } - len = read(fd, out, SYSFS_PATH_MAX); + len = read(fd, out, size); if (len < 0) { syslog_dbg("Failed to read %s\n", path); close(fd); @@ -1731,14 +1738,14 @@ } /** - * ipr_add_slot - + * ipr_add_slot_location - * @path: path of device/file to open * @name: name of device/file to open * * Returns: * 0 if success / non-zero on failure **/ -static int ipr_add_slot(char *path, char *name) +static int ipr_add_slot_location(char *path, char *name) { struct ipr_pci_slot *slot; char fpath[SYSFS_PATH_MAX]; @@ -1751,13 +1758,50 @@ memset(slot, 0, sizeof(*slot)); strcpy(slot->slot_name, name); - rc = read_slot_attr(fpath, slot->physical_name); + rc = read_attr_file(fpath, slot->physical_name, + sizeof(slot->physical_name)); + + if (rc) { + pci_slot = realloc(pci_slot, sizeof(*pci_slot) * num_pci_slots); + return rc; + } + + num_pci_slots++; + return 0; +} + +/** + * ipr_add_slot_address - + * @path: path of device/file to open + * @name: name of device/file to open + * + * Returns: + * 0 if success / non-zero on failure + **/ +static int ipr_add_slot_address(char *path, char *name) +{ + struct ipr_pci_slot *slot; + char fpath[SYSFS_PATH_MAX]; + int rc; + + sprintf(fpath, "%s%s/address", path, name); + + pci_slot = realloc(pci_slot, sizeof(*pci_slot) * (num_pci_slots + 1)); + slot = &pci_slot[num_pci_slots]; + memset(slot, 0, sizeof(*slot)); + + strcpy(slot->slot_name, name); + strcpy(slot->physical_name, name); + rc = read_attr_file(fpath, slot->pci_device, + sizeof(slot->pci_device)); if (rc) { pci_slot = realloc(pci_slot, sizeof(*pci_slot) * num_pci_slots); return rc; } + strcat(slot->pci_device, ".0"); + num_pci_slots++; return 0; } @@ -1772,7 +1816,10 @@ { char rootslot[SYSFS_PATH_MAX], slot[SYSFS_PATH_MAX]; char slotpath[SYSFS_PATH_MAX], attr[SYSFS_PATH_MAX]; + char devspec[PATH_MAX], locpath[PATH_MAX]; + char loc_code[1024], *last_hyphen, *prev_hyphen; int num_slots, i, j, rc, num_attrs; + int slot_found = 0; struct dirent **slotdir, **dirent; struct stat statbuf; struct ipr_ioa *ioa; @@ -1792,13 +1839,23 @@ for (i = 0; i < num_slots; i++) { sprintf(slot, "%s%s", rootslot, slotdir[i]->d_name); rc = scandir(slot, &dirent, ipr_select_phy_location, alphasort); - if (rc <= 0) - continue; + if (rc > 0) { + ipr_add_slot_location(rootslot, slotdir[i]->d_name); + while (rc--) + free(dirent[rc]); + free(dirent); + } else { + rc = scandir(slot, &dirent, ipr_select_pci_address, + alphasort); - ipr_add_slot(rootslot, slotdir[i]->d_name); - while (rc--) - free(dirent[rc]); - free(dirent); + if (rc <= 0) + continue; + + ipr_add_slot_address(rootslot, slotdir[i]->d_name); + while (rc--) + free(dirent[rc]); + free(dirent); + } } while (num_slots--) @@ -1806,6 +1863,10 @@ free(slotdir); for (i = 0; i < num_pci_slots; i++) { + + if (!pci_slot[i].pci_device) + continue; + sprintf(slotpath, "%s/"SYSFS_DEVICES_NAME"/%s/", sysfs_bus->path, pci_slot[i].slot_name); @@ -1837,12 +1898,42 @@ ioa->physical_location[0] = '\0'; for_each_ioa(ioa) { + slot_found = 0; for (i = 0; i < num_pci_slots; i++) { - if (strcmp(pci_slot[i].pci_device, ioa->pci_address)) + if (strcmp(pci_slot[i].pci_device, ioa->pci_address) && + strcmp(pci_slot[i].slot_name, ioa->pci_address)) continue; - strcpy(ioa->physical_location, pci_slot[i].physical_name); + strcpy(ioa->physical_location, + pci_slot[i].physical_name); + slot_found = 1; break; } + if (!slot_found) { + sprintf(attr, "%s/"SYSFS_DEVICES_NAME"/%s/devspec", + sysfs_bus->path, ioa->pci_address); + rc = read_attr_file(attr, devspec, PATH_MAX); + + if (rc) + continue; + + sprintf(locpath, "/proc/device-tree%s/ibm,loc-code", + devspec); + rc = read_attr_file(locpath, loc_code, + sizeof(loc_code)); + + if (rc) + continue; + + last_hyphen = strrchr(loc_code, '-'); + if (last_hyphen && last_hyphen[1] == 'T') { + *last_hyphen = '\0'; + prev_hyphen = strrchr(loc_code, '-'); + if (prev_hyphen && prev_hyphen[1] != 'C') + *last_hyphen = '-'; + } + + strcpy(ioa->physical_location, loc_code); + } } free(pci_slot); @@ -3770,6 +3861,7 @@ * Returns: * device generic name for now - see FIXME below **/ +#if 0 static char *get_write_buffer_dev(struct ipr_dev *dev) { struct sysfs_class_device *class_device; @@ -3819,6 +3911,7 @@ sysfs_close_class_device(class_device); return dev->gen_name; } +#endif /** * ipr_resume_device_bus - Index: iprconfig.c =================================================================== RCS file: /cvsroot/iprdd/iprutils/iprconfig.c,v retrieving revision 1.140 retrieving revision 1.141 diff -u -d -r1.140 -r1.141 --- iprconfig.c 14 Aug 2009 17:36:31 -0000 1.140 +++ iprconfig.c 30 Oct 2009 18:46:39 -0000 1.141 @@ -11747,6 +11747,7 @@ char *gen_name = dev->gen_name; char node_name[7], buf[100], raid_str[48]; int tab_stop = 0; + int loc_len = 0; char vendor_id[IPR_VENDOR_ID_LEN + 1]; char product_id[IPR_PROD_ID_LEN + 1]; struct ipr_ioa *ioa = dev->ioa; @@ -11769,35 +11770,42 @@ if (option) len += sprintf(body + len, " %s ", option); - len += sprintf(body + len, "%-6s %s/%d:", - node_name, - ioa->pci_address, - ioa->host_num); + len += sprintf(body + len, "%-6s ", node_name); + loc_len = sprintf(body + len, "%s/%d:", + ioa->pci_address, + ioa->host_num); + len += loc_len; if (scsi_dev_data && scsi_dev_data->type == IPR_TYPE_ADAPTER) { + + for (i = 0; i < 27-loc_len; i++) + body[len+i] = ' '; + + len += 27-loc_len; + if (!vpd) { - len += sprintf(body + len," %s %-19s ", get_bus_desc(ioa), + len += sprintf(body + len,"%s %-19s ", get_bus_desc(ioa), get_ioa_desc(dev->ioa)); } else - len += sprintf(body + len," %-8s %-16s ", + len += sprintf(body + len,"%-8s %-16s ", scsi_dev_data->vendor_id, scsi_dev_data->product_id); } else if (scsi_dev_data && scsi_dev_data->type == IPR_TYPE_EMPTY_SLOT) { - tab_stop = sprintf(body + len,"%d:%d: ", - dev->res_addr[ra].bus, - dev->res_addr[ra].target); + loc_len += sprintf(body + len,"%d:%d: ", + dev->res_addr[ra].bus, + dev->res_addr[ra].target); - len += tab_stop; + len += loc_len; - for (i = 0; i < 12-tab_stop; i++) + for (i = 0; i < 27-loc_len; i++) body[len+i] = ' '; - len += 12-tab_stop; - len += sprintf(body + len, "%-8s %-16s "," ", " "); + len += 27-loc_len; + len += sprintf(body + len, "%-8s %-16s ", " ", " "); } else { - tab_stop = sprintf(body + len,"%d:%d:%d ", dev->res_addr[ra].bus, - dev->res_addr[ra].target, dev->res_addr[ra].lun); + tab_stop = sprintf(body + len,"%d:%d:%d ", dev->res_addr[ra].bus, + dev->res_addr[ra].target, dev->res_addr[ra].lun); if (scsi_dev_data) { ipr_strncpy_0(vendor_id, scsi_dev_data->vendor_id, IPR_VENDOR_ID_LEN); @@ -11813,12 +11821,13 @@ } } + loc_len += tab_stop; len += tab_stop; - for (i = 0; i < 12-tab_stop; i++) + for (i = 0; i < 27-loc_len; i++) body[len+i] = ' '; - len += 12-tab_stop; + len += 27-loc_len; if (vpd) { len += sprintf(body + len, "%-8s %-16s ", @@ -14902,6 +14911,8 @@ body = ioa_details(body, dev); else if (ipr_is_volume_set(dev)) body = vset_details(body, dev); + else if (ipr_is_ses(dev)) + body = ses_details(body, dev); else body = disk_details(body, dev); |