MS-DOS File System questions - partitions, mounting, files - RESOLVED
Robert S. Grimes
rsg at alum.mit.edu
Fri Oct 10 15:30:59 UTC 2008
Oops! Sorry, bad form and all, but it was indeed my inexperience -
sorry to waste the bandwidth on this. In the hopes of helping someone
else, I will point out my errors:
1. First, this function is sufficient for mounting the MSDOS filesystem
on my partition on the SD Card.
> CHECK_RVSC( rv, "Create mount point");
> rv = rtems_fsmount(fsTable, sizeof(fsTable) / sizeof(fsTable[0]), NULL);
> CHECK_RVSC( rv, "Mount file systems");
>
>
This is, as far as I can tell, an alternate way of doing it:
> rtems_filesystem_mount_table_entry_t* mtEntry;
> if (mount(&mtEntry, &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
> "/dev/sdcarda1", "/mnt/dirone") < 0) {
> printf("mount: mount failed: %s\n", strerror (errno));
> }
>
One does not need both!
2. Of course, because the rtems_fsmount() call was successful, and the
mount() failure is essentially a no-op, the print directory calls, and
the open()/read()/close() sequence works fine.
3. The mkdir()/chdir() combinations only partially worked because I
didn't unmount() before ending the session, and hence, not all changes
made it to the SD card; I think this explains why the directory
sometimes showed up or not, or was corrupted or no, in Windows.
4. The open() call to write to a (non-existent) file fails as you might
expect - I forgot the O_CREAT flag.
Now, all is working fine!
-Bob
> // This doesn't work, but maybe that is because the mount() fails?
> If so, would this be correct
> // if mount() had succeeded?
> int writeme = open("newfile.txt", O_WRONLY);
> printf("\nCreating newfile.txt, returned %d\n", writeme);
> if (writeme > 0) {
> sprintf(linebuf, "Hello, world!\n");
> write(writeme, linebuf, strlen(linebuf)+1);
> close(writeme);
> }
>
> // Same question as previous open()
> writeme = open("/mnt/newfile.txt", O_WRONLY);
> printf("\nCreating /mnt/newfile.txt, returned %d\n", writeme);
> if (writeme > 0) {
> sprintf(linebuf, "Hello, world!\n");
> write(writeme, linebuf, strlen(linebuf)+1);
> close(writeme);
> }
>
>
> Here is the output from the above code:
>
> Print /dev directory
> <console>
> <spi0.sdcarda>
> <sdcarda>
> <sdcarda1>
> Returned 0
>
> Print /mnt directory
> <README.TXT>
> <DIRONE>
> <README1.TXT>
> <DIRTWO>
> <README2.TXT>
> <TESTDIR3>
> Returned 0
>
> mount: mount failed: Not supported
> Readme contains: [This is a simple text file.]
>
> Make a directory and move to it
> Returned: -1
> printDir returned 0
> Change directory returned 0
>
> Creating newfile.txt, returned -1
>
> Creating /mnt/newfile.txt, returned -1
>
> Thanks!
> -Bob
>
>
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>
>
More information about the users
mailing list