shithub: riscv

Download patch

ref: c3c7429dc264396c96a6d56831357eeb54781097
parent: c96fb5471a7dc83f0acd53e1f15da589ea13280a
author: mischief <mischief@offblast.org>
date: Sat Mar 17 11:06:13 EDT 2018

nusb/ptp: set storage name to their human readable description string

--- a/sys/src/cmd/nusb/ptp/ptp.c
+++ b/sys/src/cmd/nusb/ptp/ptp.c
@@ -526,8 +526,22 @@
 		x->handle = 0xffffffff;
 		x->d.qid.type = QTDIR;
 		x->d.mode = DMDIR|0777;
-		x->d.name = emalloc9p(10);
-		sprint(x->d.name, "%x", x->store);
+
+		if(ptprpc(r, GetStorageInfo, 1|DataRecv, NUM(path), &p, &np) < 0)
+			break;
+		if(debug)
+			hexdump("storageinfo", p, np);
+		if(np < 26){
+			werrstr("bad storageinfo");
+			break;
+		}
+
+		if((x->d.name = ptpstring2(p+26, p+np)) == nil){
+			werrstr("bad storageinfo");
+			break;
+		}
+
+		free(p);
 		goto Addnode;
 
 	case Qobj: