scsi_lib.c (35c0506f27f6e3f278592d631901163cbccce28d) | scsi_lib.c (ccf1e0045eea8f98d60fc9327bcb14c958d2e4c7) |
---|---|
1/* 2 * Copyright (C) 1999 Eric Youngdale 3 * Copyright (C) 2014 Christoph Hellwig 4 * 5 * SCSI queueing library. 6 * Initial versions: Eric Youngdale (eric@andante.org). 7 * Based upon conversations with large numbers 8 * of people at Linux Expo. --- 3258 unchanged lines hidden (view full) --- 3267 * Returns the length of the identification or error on failure. 3268 * If the identifier is longer than the supplied buffer the actual 3269 * identifier length is returned and the buffer is not zero-padded. 3270 */ 3271int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, size_t id_len) 3272{ 3273 u8 cur_id_type = 0xff; 3274 u8 cur_id_size = 0; | 1/* 2 * Copyright (C) 1999 Eric Youngdale 3 * Copyright (C) 2014 Christoph Hellwig 4 * 5 * SCSI queueing library. 6 * Initial versions: Eric Youngdale (eric@andante.org). 7 * Based upon conversations with large numbers 8 * of people at Linux Expo. --- 3258 unchanged lines hidden (view full) --- 3267 * Returns the length of the identification or error on failure. 3268 * If the identifier is longer than the supplied buffer the actual 3269 * identifier length is returned and the buffer is not zero-padded. 3270 */ 3271int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, size_t id_len) 3272{ 3273 u8 cur_id_type = 0xff; 3274 u8 cur_id_size = 0; |
3275 unsigned char *d, *cur_id_str; 3276 unsigned char __rcu *vpd_pg83; | 3275 const unsigned char *d, *cur_id_str; 3276 const struct scsi_vpd *vpd_pg83; |
3277 int id_size = -EINVAL; 3278 3279 rcu_read_lock(); 3280 vpd_pg83 = rcu_dereference(sdev->vpd_pg83); 3281 if (!vpd_pg83) { 3282 rcu_read_unlock(); 3283 return -ENXIO; 3284 } --- 14 unchanged lines hidden (view full) --- 3299 3300 /* The id string must be at least 20 bytes + terminating NULL byte */ 3301 if (id_len < 21) { 3302 rcu_read_unlock(); 3303 return -EINVAL; 3304 } 3305 3306 memset(id, 0, id_len); | 3277 int id_size = -EINVAL; 3278 3279 rcu_read_lock(); 3280 vpd_pg83 = rcu_dereference(sdev->vpd_pg83); 3281 if (!vpd_pg83) { 3282 rcu_read_unlock(); 3283 return -ENXIO; 3284 } --- 14 unchanged lines hidden (view full) --- 3299 3300 /* The id string must be at least 20 bytes + terminating NULL byte */ 3301 if (id_len < 21) { 3302 rcu_read_unlock(); 3303 return -EINVAL; 3304 } 3305 3306 memset(id, 0, id_len); |
3307 d = vpd_pg83 + 4; 3308 while (d < vpd_pg83 + sdev->vpd_pg83_len) { | 3307 d = vpd_pg83->data + 4; 3308 while (d < vpd_pg83->data + vpd_pg83->len) { |
3309 /* Skip designators not referring to the LUN */ 3310 if ((d[1] & 0x30) != 0x00) 3311 goto next_desig; 3312 3313 switch (d[1] & 0xf) { 3314 case 0x1: 3315 /* T10 Vendor ID */ 3316 if (cur_id_size > d[3]) --- 99 unchanged lines hidden (view full) --- 3416 * 3417 * Returns the Target Port Group identifier from the information 3418 * froom VPD page 0x83 of the device. 3419 * 3420 * Returns the identifier or error on failure. 3421 */ 3422int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) 3423{ | 3309 /* Skip designators not referring to the LUN */ 3310 if ((d[1] & 0x30) != 0x00) 3311 goto next_desig; 3312 3313 switch (d[1] & 0xf) { 3314 case 0x1: 3315 /* T10 Vendor ID */ 3316 if (cur_id_size > d[3]) --- 99 unchanged lines hidden (view full) --- 3416 * 3417 * Returns the Target Port Group identifier from the information 3418 * froom VPD page 0x83 of the device. 3419 * 3420 * Returns the identifier or error on failure. 3421 */ 3422int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) 3423{ |
3424 unsigned char *d; 3425 unsigned char __rcu *vpd_pg83; | 3424 const unsigned char *d; 3425 const struct scsi_vpd *vpd_pg83; |
3426 int group_id = -EAGAIN, rel_port = -1; 3427 3428 rcu_read_lock(); 3429 vpd_pg83 = rcu_dereference(sdev->vpd_pg83); 3430 if (!vpd_pg83) { 3431 rcu_read_unlock(); 3432 return -ENXIO; 3433 } 3434 | 3426 int group_id = -EAGAIN, rel_port = -1; 3427 3428 rcu_read_lock(); 3429 vpd_pg83 = rcu_dereference(sdev->vpd_pg83); 3430 if (!vpd_pg83) { 3431 rcu_read_unlock(); 3432 return -ENXIO; 3433 } 3434 |
3435 d = sdev->vpd_pg83 + 4; 3436 while (d < sdev->vpd_pg83 + sdev->vpd_pg83_len) { | 3435 d = vpd_pg83->data + 4; 3436 while (d < vpd_pg83->data + vpd_pg83->len) { |
3437 switch (d[1] & 0xf) { 3438 case 0x4: 3439 /* Relative target port */ 3440 rel_port = get_unaligned_be16(&d[6]); 3441 break; 3442 case 0x5: 3443 /* Target port group */ 3444 group_id = get_unaligned_be16(&d[6]); --- 14 unchanged lines hidden --- | 3437 switch (d[1] & 0xf) { 3438 case 0x4: 3439 /* Relative target port */ 3440 rel_port = get_unaligned_be16(&d[6]); 3441 break; 3442 case 0x5: 3443 /* Target port group */ 3444 group_id = get_unaligned_be16(&d[6]); --- 14 unchanged lines hidden --- |