xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

資源簡(jiǎn)介

linux下實(shí)現(xiàn)自動(dòng)查找U盤,識(shí)別U盤,判斷是否已經(jīng)掛載(如果沒有則自動(dòng)掛載),然后在U盤創(chuàng)建文件,最后卸載U盤。 純C代碼,全部源代碼,可以在fedora等桌面linux上使用,也可以在嵌入式linux下使用,測(cè)試通過。 基本原理是: 1)打開 /proc/scsi/usb-storage 目錄,如果能打開說(shuō)明有U盤或者移動(dòng)硬盤接入,否則沒有 如果有則獲取移動(dòng)設(shè)備的設(shè)備號(hào),就是文件名,打開這個(gè)文件名從里面可以提前設(shè)備的序列號(hào) 2)根據(jù)設(shè)備號(hào),在/sys/class/scsi_device/目錄去找,找以該設(shè)備號(hào)開頭的文件夾 這個(gè)時(shí)候需要遍歷這些文件夾了 3)遍歷過程: 打開其下的device

資源截圖

代碼片段和文件信息

#include???
#include???
#include???
#include???
#include???
#include???
#include???

#define?SCSI_DEV_DIR?“/sys/class/scsi_device“

int?check_sd_sub_dir(char?*dirnamechar?*diskname)
{
char?*seek_sd?=?NULL;
DIR?*dirp?=?NULL;??
struct?dirent?*direntp?=?NULL;??
int?count?=?0;

if?((dirp?=?opendir(dirname))?==?NULL)?{??
????????printf(“sub?funciton?Open?Directory?%s?Error:%s\n“??
????????????????dirname?strerror(errno));??
????????return?-1;?//no?block?dir?not?usb?disk?device
??}
??//可能存在多個(gè)分區(qū),取第一個(gè)吧
??while?((direntp?=?readdir(dirp))?!=?NULL){??
???????if?(strcmp(“.“?direntp->d_name)?==?0?||
????????????????????strcmp(“..“?direntp->d_name)?==?0)
????????{
????????????continue;
????????}

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件????????127??2019-10-25?10:54??make.txt

?????文件???????2560??2019-10-25?10:49??mount.c

?????文件???????2646??2019-10-25?10:52??readSn.c

?????文件???????3968??2019-08-29?09:37??getUdiskName.c

?????文件???????1885??2019-10-25?10:51??main.c

-----------?---------??----------?-----??----

????????????????11186????????????????????5


評(píng)論

共有 條評(píng)論