[rtems commit] dosfs: Add sync_device option for msdos_format()
Sebastian Huber
sebh at rtems.org
Thu Dec 13 10:35:14 UTC 2012
Module: rtems
Branch: master
Commit: 4b8e01f7c559ef661910d013347513221f3baca7
Changeset: http://git.rtems.org/rtems/commit/?id=4b8e01f7c559ef661910d013347513221f3baca7
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Dec 13 11:08:03 2012 +0100
dosfs: Add sync_device option for msdos_format()
---
cpukit/libfs/src/dosfs/dosfs.h | 5 +++++
cpukit/libfs/src/dosfs/msdos_format.c | 5 +++++
testsuites/fstests/fsdosfssync01/init.c | 7 ++++++-
3 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/cpukit/libfs/src/dosfs/dosfs.h b/cpukit/libfs/src/dosfs/dosfs.h
index 4857466..2374e63 100644
--- a/cpukit/libfs/src/dosfs/dosfs.h
+++ b/cpukit/libfs/src/dosfs/dosfs.h
@@ -95,6 +95,11 @@ typedef struct {
bool skip_alignment;
/**
+ * @brief Synchronize device after write operations.
+ */
+ bool sync_device;
+
+ /**
* @brief The amount of info to output.
*/
int info_level;
diff --git a/cpukit/libfs/src/dosfs/msdos_format.c b/cpukit/libfs/src/dosfs/msdos_format.c
index 0bf3f39..0b30caf 100644
--- a/cpukit/libfs/src/dosfs/msdos_format.c
+++ b/cpukit/libfs/src/dosfs/msdos_format.c
@@ -1251,6 +1251,11 @@ int msdos_format
tmp_sec);
}
}
+
+ if (ret_val == 0 && rqdata != NULL && rqdata->sync_device) {
+ ret_val = rtems_disk_fd_sync(fd);
+ }
+
/*
* cleanup:
* sync and unlock disk
diff --git a/testsuites/fstests/fsdosfssync01/init.c b/testsuites/fstests/fsdosfssync01/init.c
index 72481b2..fc38e2c 100644
--- a/testsuites/fstests/fsdosfssync01/init.c
+++ b/testsuites/fstests/fsdosfssync01/init.c
@@ -89,6 +89,11 @@ static void check_file_size(const char *file, off_t size)
static void test(const char *rda, const char *mnt, const char *file)
{
+ static const msdos_format_request_param_t rqdata = {
+ .quick_format = true,
+ .sync_device = true
+ };
+
rtems_status_code sc;
int disk_fd;
int rv;
@@ -99,7 +104,7 @@ static void test(const char *rda, const char *mnt, const char *file)
disk_fd = open(rda, O_RDWR);
rtems_test_assert(disk_fd >= 0);
- rv = msdos_format(rda, NULL);
+ rv = msdos_format(rda, &rqdata);
rtems_test_assert(rv == 0);
rv = mount_and_make_target_path(
More information about the vc
mailing list