|
#include "sys/shm.h"
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <linux/sockios.h>
#include <linux/ethtool.h>
#include <unistd.h>
void main(void* arg)
{
//挂载u盘 /mnt/usbdisk/sda1到/mnt/userdata1/temp
char chOrder[128]="mount /mnt/usbdisk/sda1 /mnt/userdata1/temp";
char chOrder1[128]="cp -rf /mnt/userdata1/temp/* /mnt/userdata1/temp2";
char chOrder2[128]="chmod 777 /mnt/userdata1/temp2/*";
char chOrder3[128]="umount /mnt/userdata1/temp";
static int oldst = 0;
static int curst = 0;
while(1)
{
if( access("/dev/uba1",F_OK)== 0)//判断usb设备是否存在
{
//printf("/dev/uba1 exist\n");
curst = 1;
//printf("cur = %d,old = %d\n",curst,oldst);
}
else
{
//printf("/dev/uba1 no exist\n");
curst = 0;
}
if(oldst == 0 && curst == 1)
{
system(chOrder);
printf("mount success\n");
system(chOrder1);
printf("copy success\n");
system(chOrder2);
printf("chmod success\n");
system(chOrder3);
printf("umount success\n");
}
oldst = curst;
sleep(5);
}
}
参考博文原文链接:https://blog.csdn.net/celerylxq/article/details/17091923
|
|