9、id.serial_no); fprintf (stdout, get hard disk serial number: %sn, id); return 0;获取MAC地址通过创建一个socket,然后bind特定的IP地址,就可以通过ioctl得到这个套按地绑定的网络接口名称。然 后再通过网络接口名称,得到MAC地址。如果ioctl的第二个参数为SIOCGIFNAME, 则获得指定网络接口的名称;如果ioctl...
ioctl第二个参数为HDIO_GET_IDENTITY, 获得指定文件描述符的标志号 ioctl的第三个参数为struct hd_driveid ,在linux/hdreg.h中,struct hd_driveid的声明有 struct hd_driveid { unsigned short config; / lots of obsolete bit flags */ unsigned short cyls; /* Obsolete, "physical" cyls */ unsigned sh...
fprintf (stdout, "get cpu id: %s\n", id); return 0; } 获取硬盘序列号 这个的实现,采用的是读取/etc/mtab文件,找到/(即根目录)挂载的设备文件,然后打开它,再用系统调用ioctl来实现的。 ioctl第二个参数为HDIO_GET_IDENTITY, 获得指定文件描述符的标志号 ioctl的第三个参数为struct hd_driveid ,在li...
ioctl第二个参数为HDIO_GET_IDENTITY, 获得指定文件描述符的标志号 ioctl的第三个参数为struct hd_driveid ,在linux/hdreg.h中,struct hd_driveid的声明有 struct hd_driveid { unsigned short config; / lots of obsolete bit flags */ unsigned short cyls; /* Obsolete, "physical" cyls */ unsigned sh...
inxiis a versatile command-line tool used to gather system information in Linux. So,we can useinxito find the serial number of a given storage drive. First, let’s installinxi: $ sudo apt-get install inxiCopy Then, we useinxito get the serial number: ...
可能是你没有读取那个文件的权限,所以会导致open失败.通常对于这种系统文件都要求有root权限,看看你是否有权限吧.
,这其中,serial_no为硬盘的序列号。如果此项为0,则为没有提供。 思路明确了,以下为实现代码: static int getdiskid (char *id, size_t max) { int fd; struct hd_driveid hid; FILE *fp; char line[0x100], *disk, *root, *p; fp = fopen ("/etc/mtab", "r"); ...
The numbers before the dates in the first two lines of Example 3-1 are the major and minor device numbers that help the kernel identify the device. Similar devices usually have the same major number, such as sda3 and sdb1 (both of which are hard disk partitions). 示例3-1的前两行中日...
Vendor serial number The Ethernet NIC obtains the EEPROM data of the optical module by using the ioctl interface of the driver, and then parses the data based on the optical module protocol. The IB NIC uses the latest mlxlink tool to obtain data for parsing. BOM code The Ethernet NIC...
The UUID is a type of serial number, and each one should be different. Filesystem creation programs like mke2fs generate a UUID identifier when initializing the filesystem data structure. 在前面的章节中讨论的挂载文件系统的方法依赖于设备名称。