Mercurial > hg > toybox
annotate toys/pending/lspci.c @ 1005:03f72b57a092
DHCP client and server, from Ashwini Sharma.
author  Rob Landley <rob@landley.net> 

date  Wed, 14 Aug 2013 19:09:33 0500 
parents  8caeba551a28 
children  9b3818b2a054 
rev  line source 

968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

1 /* 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

2 * lspci  written by Isaac Dunham 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

3 
990
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

4 USE_LSPCI(NEWTOY(lspci, "emkn@", TOYFLAG_USRTOYFLAG_BIN)) 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

5 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

6 config LSPCI 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

7 bool "lspci" 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

8 default n 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

9 help 
990
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

10 usage: lspci [ekmn@] 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

11 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

12 List PCI devices. 
969
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

13 e Print all 6 digits in class (like elspci) 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

14 k Print kernel driver 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

15 m Machine parseable format 
990
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

16 n Numeric output 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

17 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

18 config LSPCI_TEXT 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

19 bool "lspci readable output" 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

20 depends on LSPCI 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

21 default n 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

22 help 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

23 lspci without n prints readable descriptions; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

24 lspci nn prints both readable and numeric description 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

25 */ 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

26 #define FOR_lspci 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

27 #include "toys.h" 
990
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

28 extern int find_in_db(char * , char * , FILE * , char * , char * ); 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

29 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

30 GLOBALS( 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

31 long numeric; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

32 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

33 FILE * db; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

34 ) 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

35 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

36 char * id_check_match(char * id, char * buf) 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

37 { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

38 int i = 0; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

39 while (id[i]) { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

40 if (id[i] == buf[i]) { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

41 i++; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

42 } else { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

43 return (char *)0L; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

44 } 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

45 } 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

46 return (buf + i + 2); 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

47 } 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

48 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

49 /* 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

50 * In: vendid, devid, fil 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

51 * Out: vname, devname 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

52 * Out must be zeroed before use. 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

53 * vmame and devname must be char[256], zeroed out 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

54 * Returns (2  number of IDs matched): vendor must be matched for 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

55 * dev to be matched 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

56 */ 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

57 int find_in_db(char * vendid, char * devid, FILE * fil, 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

58 char * vname, char * devname) 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

59 { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

60 fseek(fil, 0, SEEK_SET); 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

61 char buf[256], *vtext = 0L, *dtext = 0L; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

62 while (!(vname[0])) { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

63 //loop through 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

64 if (fgets(buf, 255, fil)==NULL) return 2; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

65 if ((vtext = id_check_match(vendid, buf))) 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

66 strncpy(vname, vtext, strlen(vtext)  1); 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

67 } 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

68 while (!(devname[0])) { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

69 if ((fgets(buf, 255, fil)==NULL)  (buf[0] != '\t' )) 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

70 return 1; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

71 if ((dtext = id_check_match(devid, buf + 1))) 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

72 strncpy(devname, dtext, strlen(dtext)  1); 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

73 } 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

74 return 0; /* Succeeded in matching both */ 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

75 } 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

76 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

77 int do_lspci(struct dirtree *new) 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

78 { 
990
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

79 int alen = 8, dirfd, res = 2; //no textual descriptions read 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

80 char *dname = dirtree_path(new, &alen); 
990
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

81 memset(toybuf, 0, 4096); 
969
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

82 struct { 
990
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

83 char class[16], vendor[16], device[16], module[256], 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

84 vname[256], devname[256]; 
969
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

85 } *bufs = (void*)(toybuf + 2); 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

86 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

87 if (!strcmp("/sys/bus/pci/devices", dname)) return DIRTREE_RECURSE; 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

88 errno = 0; 
969
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

89 dirfd = open(dname, O_RDONLY); 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

90 if (dirfd > 0) { 
969
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

91 char *p, **fields = (char*[]){"class", "vendor", "device", ""}; 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

92 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

93 for (p = toybuf; **fields; p+=16, fields++) { 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

94 int fd, size; 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

95 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

96 if ((fd = openat(dirfd, *fields, O_RDONLY)) < 0) continue; 
976  97 size = ((toys.optflags & FLAG_e) && (p == toybuf)) ? 8 : 6; 
969
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

98 p[read(fd, p, size)] = '\0'; 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

99 close(fd); 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

100 } 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

101 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

102 close(dirfd); 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

103 if (!errno) { 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

104 char *driver = ""; 
969
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

105 char *fmt = toys.optflags & FLAG_m ? "%s, \"%s\" \"%s\" \"%s\" \"%s\"\n" 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

106 : "%s Class %s: %s:%s %s\n"; 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

107 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

108 if (toys.optflags & FLAG_k) { 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

109 strcat(dname, "/driver"); 
969
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

110 if (readlink(dname, bufs>module, sizeof(bufs>module)) != 1) 
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

111 driver = basename(bufs>module); 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

112 } 
990
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

113 if (CFG_LSPCI_TEXT && (TT.numeric != 1)) { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

114 res = find_in_db(bufs>vendor, bufs>device, TT.db, 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

115 bufs>vname, bufs>devname); 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

116 } 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

117 if (CFG_LSPCI_TEXT && (TT.numeric == 2)) { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

118 fmt = toys.optflags & FLAG_m 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

119 ? "%s, \"%s\" \"%s [%s]\" \"%s [%s]\" \"%s\"\n" 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

120 : "%s Class %s: %s [%s] %s [%s] %s\n"; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

121 printf(fmt, new>name + 5, bufs>class, bufs>vname, bufs>vendor, 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

122 bufs>devname, bufs>device, driver); 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

123 } else { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

124 printf(fmt, new>name + 5, bufs>class, 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

125 (res < 2) ? bufs>vname : bufs>vendor, 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

126 !(res) ? bufs>devname : bufs>device, driver); 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

127 } 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

128 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

129 } 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

130 } 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

131 return 0; 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

132 } 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

133 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

134 void lspci_main(void) 
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

135 { 
990
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

136 if (CFG_LSPCI_TEXT && (TT.numeric != 1)) { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

137 TT.db = fopen("/usr/share/misc/pci.ids", "r"); 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

138 if (errno) { 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

139 TT.numeric = 1; 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

140 error_msg("could not open PCI ID db"); 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

141 } 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

142 } 
8caeba551a28
This is the preliminary version of lspci text output support (the location
Isaac Dunham <idunham@lavabit.com>
parents:
976
diff
changeset

143 
969
a47c6658210c
lspci: use toybuf instead of dynamic memory allocation
Felix Janda <felix.janda@posteo.de>
parents:
968
diff
changeset

144 dirtree_read("/sys/bus/pci/devices", do_lspci); 
968
b2b4bd208b65
I've written an lspci implementation.
Isaac Dunham <idunham@lavabit.com>
parents:
diff
changeset

145 } 