微嵌工业平板开发论坛

 找回密码
 立即注册
搜索
热搜: android wince6.0
查看: 513|回复: 0

linux使用u盘在线更新软件程序

[复制链接]

96

主题

28

回帖

3097

积分

论坛元老

Rank: 8Rank: 8

积分
3097
发表于 2022-3-10 17:57:47 | 显示全部楼层 |阅读模式
#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

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|微嵌工业平板开发论坛

GMT+8, 2024-12-22 12:11 , Processed in 0.021529 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表