当前位置: 代码迷 >> 驱动开发 >> usb 测试程序 mount 失败解决办法
  详细解决方案

usb 测试程序 mount 失败解决办法

热度:114   发布时间:2016-04-28 10:41:34.0
usb 测试程序 mount 失败
本帖最后由 barca1202 于 2012-11-11 15:09:42 编辑 大家好,

我写了个usb的测试程序,目的是进行以下一些测试,attach/detach, mount/unmount, opendir/readdir/closedir, open file/read file/close file. 运行程序可以检测到 attach/detach, 但是mount失败。想请教一下问题出在哪里,怎么改正,谢谢各位。附上代码。



/*........................... FILE PROLOGUE ..........................*/
/*
.FP
 ***********************************************************************
 *
 *  FILE NAME:
 *    usb_test_case.c
 *
 *  PURPOSE:
 *    This file is used to verify that the API calls used to access and control the USB drive.
 *    DLE can use to determine when the USB drive has been detached during use.
 ***********************************************************************
.FP END
*/

/* ------------------------------ FILE INCLUSION ----------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>              /* Standard types */
#include <stdint.h>                 /* for integer types*/
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sched.h>
#include <fcntl.h>
#include <sys/file.h>
#include <time.h>
#include <usb.h>
#include <unistd.h>
#include <dirent.h>
#include <io.h>
#include <unistd.h>
#include <errno.h>

static char* blocknode = "/dev/ddev/sdusb";
static char* charnode = "/dev/ddev/usb.ctrl";
static char* mountpoint_1 = "/tmp/tftproot";
static char* mountpoint = "/tmp/tftproot/usb";
static int fh1;
static unsigned int bytesread;

void wait_for_event(int read_fd);
void walk_dir(const char *file);
void access_read(const char *file);
void open_file(void);
void read_file(void);
void close_file(void);

#define SCSI_DRIVER_MOUNT 1

#define   SUC   0
#define   ERR   1

/*
*******************************************************************************
-*
-*   NAME:
-*     wait_for_event
-*
-*   PURPOSE:
-*     This function is used to discover if any changes has happened on the USB port
-*     or not and read the events generated by USB driver.
-*
-*   PARAMETERS:
-*
-*      INPUT: int read_fd - USB character device file handle
-*
-*      OUTPUT: None
-*
-*   RETURNS: None
-*
-*   NOTES: None
-*
*******************************************************************************
*/

void wait_for_event(int read_fd)
{
  usb_event *event = NULL;
  相关解决方案