Thread-topic: How to write a file to a USB flash memory stick?
Hi all,
I am writing a program that first identifies a plug-in flash memory
stick by matching IOMedeiaClass with a group values and then getting its
BSD path.
I want to read and write data to this flash memory stick.
Test 1:
Assume the stick is a disk /dev/disk1s1 that has a test file called
test.txt; I have a piece of code:
char *filename = "/dev/disk1s1/test.txt";
int fd = open(fileName, O_RDWR | O_CREAT);
run this code and I got the values
fd = -1
Question: why I cannot open a file on this stick?
Test 2:
Assume the stick is a raw disk; I have a piece of code:
char *bsdPath = "/dev/rdisk1s1";
int fd = open(bsdPath, O_RDWR | O_CREAT);
ssize_t numBytes = read(fd, inBuffer,10);
or
numBytes = write(fd, "test", 4);
run this code and I got the values
fd = 9, numBytes = -1 for either read or write
Question: why I can open this raw disk but cannot read and write data to
it?
On Desktop I can copy a file onto the stick.
Thanks,
Ben
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden
This email sent to email@hidden