hi all:
I try 2 methods today but there is no read command firing from usb
host to device
(I double check the existence of command by CATC protocol analyzer)
appreciate all your kind suggestion.
1. use busybox like below command
dd if=/dev/sda1 of=/dev/null bs=512 count=1 conv=sync
my dd in busybox doesn't have iflags option
# ./busybox.new dd help
BusyBox v1.19.2 (2014-07-09 13:43:36 CST) multi-call binary.
Usage: dd [if=FILE] [of=FILE] [ibs=N] [obs=N] [bs=N] [count=N] [skip=N]
[seek=N] [conv=notrunc|noerror|sync|fsync]
Copy a file with converting and formatting
if=FILE Read from FILE instead of stdin
of=FILE Write to FILE instead of stdout
bs=N Read and write N bytes at a time
ibs=N Read N bytes at a time
obs=N Write N bytes at a time
count=N Copy only N input blocks
skip=N Skip N input blocks
seek=N Skip N output blocks
conv=notrunc Don't truncate output file
conv=noerror Continue after read errors
conv=sync Pad blocks with zeros
conv=fsync Physically write data out before finishing
2. write c source file and open with O_DIRECT flag.
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
char message[] = "/mnt/usb/4854344154343452/test.txt";
int main()
{
int fd;
char buffer[5];
int count = 0;
char *buf="1234567890";
if((fd=open(message,O_CREAT|O_TRUNC|O_RDWR|O_DIRECT, 0777))<0)
{
perror("open");
return -1;
}
printf("fd=%d\n", fd);
write(fd, buf, strlen(buf));
while(1){
lseek(fd,0,SEEK_SET);
sleep(3);
count = read(fd, buffer, 3);
printf("count=%d,%x,%x,%x\n", count,buffer[0],buffer[1],buffer[2]);
}
}
2014-07-09 16:37 GMT+08:00 David Laight <[email protected]>:
> From: loody
> ...
>> but what it really do is read sector, not media_change or test_unit_ready.
>
> Maybe one of the programs that reads the mbr partition table can
> be persuaded to do a direct read?
>
> David
>
--
Regards,
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html