<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 29, 2012 at 9:32 AM, Ralf Kirchner <span dir="ltr"><<a href="mailto:ralf.kirchner@embedded-brains.de" target="_blank">ralf.kirchner@embedded-brains.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Add skip_aligment parameter of msdos_format_request_param_t.  Delete<br>
cluster_align parameter of msdos_format_request_param_t.<br>
<br>
By default the FAT, data cluster, and root directory for FAT12 and FAT16<br>
is aligned on a cluster boundary to optimize performance.<br>
<br>
Format changes throughout.<br>
---<br>
 cpukit/libfs/src/dosfs/dosfs.h                 |    9 +-<br>
 cpukit/libfs/src/dosfs/fat.h                   |    1 +<br>
 cpukit/libfs/src/dosfs/msdos_format.c          |  231 ++++++++++++++----------<br>
 cpukit/libmisc/shell/main_msdosfmt.c           |    4 +-<br>
 testsuites/fstests/mdosfs_support/fs_support.c |    2 +-<br>
 5 Dateien geändert, 143 Zeilen hinzugefügt(+), 104 Zeilen entfernt(-)<br>
<br>
diff --git a/cpukit/libfs/src/dosfs/dosfs.h b/cpukit/libfs/src/dosfs/dosfs.h<br>
index 93d7789..530d23e 100644<br>
--- a/cpukit/libfs/src/dosfs/dosfs.h<br>
+++ b/cpukit/libfs/src/dosfs/dosfs.h<br>
@@ -49,12 +49,9 @@ typedef struct {<br>
   uint8_t   fattype;              /* request value: MSDOS_FMT_FAT12/16/32  */<br>
   uint8_t   media;                /* media code. default: 0xF8             */<br>
   bool      quick_format;         /* true: do not clear out data sectors   */<br>
-  uint32_t  cluster_align;        /* requested value: cluster alignment    */<br>
-                                  /*   make sector number of first sector  */<br>
-                                  /*   of first cluster divisible by this  */<br>
-                                  /*   value. This can optimize clusters   */<br>
-                                  /*   to be located at start of track     */<br>
-                                  /*   or start of flash block             */<br>
+  bool      skip_alignment;       /* do not align FAT, data cluster, and   */<br>
+                                  /* root directory for FAT12 and FAT16 to */<br>
+                                  /* a cluster boundary                    */<br>
   int       info_level;           /* The amount of info to output          */<br>
 } msdos_format_request_param_t;<br>
<br>
diff --git a/cpukit/libfs/src/dosfs/fat.h b/cpukit/libfs/src/dosfs/fat.h<br>
index 260d8aa..dab2471 100644<br>
--- a/cpukit/libfs/src/dosfs/fat.h<br>
+++ b/cpukit/libfs/src/dosfs/fat.h<br>
@@ -271,6 +271,7 @@ extern "C" {<br>
 #define FAT_TOTAL_FSINFO_SIZE               512<br>
<br>
 #define MS_BYTES_PER_CLUSTER_LIMIT           0x8000     /* 32K */<br>
+#define MS_BYTES_PER_CLUSTER_LIMIT_FAT12     0x1000     /*  4K */<br>
<br>
 #define FAT_BR_EXT_FLAGS_MIRROR              0x0080<br>
<br>
diff --git a/cpukit/libfs/src/dosfs/msdos_format.c b/cpukit/libfs/src/dosfs/msdos_format.c<br>
index 974c00d..e8107a2 100644<br>
--- a/cpukit/libfs/src/dosfs/msdos_format.c<br>
+++ b/cpukit/libfs/src/dosfs/msdos_format.c<br>
@@ -64,9 +64,24 @@ typedef struct {<br>
   char     VolLabel[FAT_BR_VOLLAB_SIZE+1];<br>
   bool     VolLabel_present;<br>
   uint32_t vol_id;<br>
+  bool     skip_alignment;<br>
 }  msdos_format_param_t;<br>
<br>
 /*<br>
+ * Align to cluster borders<br>
+ */<br>
+static unsigned int<br>
+ loc_align_object (const unsigned int          sectors,<br>
+                   const unsigned int          clustersize,<br>
+                   const bool                  skip_alignment)<br>
+{<br>
+  if (! skip_alignment)<br>
+    return (sectors + clustersize - 1) & ~(clustersize - 1);<br>
+  else<br>
+    return sectors;<br>
+}<br>
+<br>
+/*<br>
  * Formatted output.<br>
  */<br>
 static void<br>
@@ -278,9 +293,12 @@ static int msdos_format_eval_sectors_per_cluster<br>
 \*-------------------------------------------------------------------------*/<br>
  int       fattype,                  /* type code of FAT (FAT_FAT12 ...) */<br>
  uint32_t  bytes_per_sector,         /* byte count per sector (512)      */<br>
- uint32_t  fatdata_sec_cnt,          /* sectors available for FAT and data */<br>
+ const uint32_t  total_sector_cnt,   /* total number of secters per volume */<br>
+ const uint32_t  rsvd_sector_cnt,    /* number of reserved sectors */<br>
+ const uint32_t  root_dir_sector_cnt,/* number of sectors for the root dir */<br>
  uint8_t   fat_num,                  /* number of fat copies             */<br>
- uint32_t  sectors_per_cluster,      /* sectors per cluster (requested)  */<br>
+ uint32_t   sectors_per_cluster,      /* sectors per cluster (requested)  */<br>
+ const bool skip_alignment,          /* true for no cluster alignment */<br>
  uint32_t *sectors_per_cluster_adj,  /* ret: sec per cluster (granted)   */<br>
  uint32_t *sectors_per_fat_ptr       /* ret: sectors needed for one FAT  */<br>
  )<br>
@@ -296,6 +314,8 @@ static int msdos_format_eval_sectors_per_cluster<br>
   uint32_t fat_capacity;<br>
   uint32_t sectors_per_fat;<br>
   uint32_t data_cluster_cnt;<br>
+  uint32_t fatdata_sect_cnt;<br>
+  uint32_t fat_sectors_cnt;<br>
   /*<br>
    * ensure, that maximum cluster size (32KByte) is not exceeded<br>
    */<br>
@@ -310,27 +330,34 @@ static int msdos_format_eval_sectors_per_cluster<br>
      * - compute storage size for FAT<br>
      * - subtract from total cluster count<br>
      */<br>
-    fatdata_cluster_cnt = fatdata_sec_cnt/sectors_per_cluster;<br>
+    fatdata_sect_cnt = total_sector_cnt -loc_align_object (rsvd_sector_cnt, sectors_per_cluster, skip_alignment);<br>
     if (fattype == FAT_FAT12) {<br>
-      fat_capacity = fatdata_cluster_cnt * 3 / 2;<br>
+      fatdata_sect_cnt    = fatdata_sect_cnt - loc_align_object (root_dir_sector_cnt, sectors_per_cluster, skip_alignment);<br></blockquote><div>Lines that are longer than 80 characters should be broken.<br><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+      fatdata_cluster_cnt = fatdata_sect_cnt/sectors_per_cluster;<br>
+      fat_capacity        = fatdata_cluster_cnt * 3 / 2;<br>
     }<br>
     else if (fattype == FAT_FAT16) {<br>
-      fat_capacity = fatdata_cluster_cnt * 2;<br>
+      fatdata_sect_cnt    = fatdata_sect_cnt - loc_align_object (root_dir_sector_cnt, sectors_per_cluster, skip_alignment);<br>
+      fatdata_cluster_cnt = fatdata_sect_cnt/sectors_per_cluster;<br>
+      fat_capacity        = fatdata_cluster_cnt * 2;<br>
     }<br>
     else { /* FAT32 */<br>
-      fat_capacity = fatdata_cluster_cnt * 4;<br>
+      fatdata_cluster_cnt = fatdata_sect_cnt/sectors_per_cluster;<br>
+      fat_capacity        = fatdata_cluster_cnt * 4;<br>
     }<br>
<br>
     sectors_per_fat = ((fat_capacity<br>
                        + (bytes_per_sector - 1))<br>
                       / bytes_per_sector);<br>
<br>
+    fat_sectors_cnt = loc_align_object (sectors_per_fat * fat_num, sectors_per_cluster, skip_alignment);<br>
+<br>
     data_cluster_cnt = (fatdata_cluster_cnt -<br>
-                       (((sectors_per_fat * fat_num)<br>
+                       ((fat_sectors_cnt<br>
                          + (sectors_per_cluster - 1))<br>
                         / sectors_per_cluster));<br>
     /*<br>
-     * data cluster count too big? then make sectors bigger<br>
+     * data cluster count too big? Then make clusters bigger<br>
      */<br>
     if (((fattype == FAT_FAT12) && (data_cluster_cnt > FAT_FAT12_MAX_CLN)) ||<br>
         ((fattype == FAT_FAT16) && (data_cluster_cnt > FAT_FAT16_MAX_CLN))) {<br>
@@ -342,7 +369,12 @@ static int msdos_format_eval_sectors_per_cluster<br>
     /*<br>
      * when maximum cluster size is exceeded, we have invalid data, abort...<br>
      */<br>
-    if ((sectors_per_cluster * bytes_per_sector)<br>
+    if (fattype == FAT_FAT12) {<br>
+      if (MS_BYTES_PER_CLUSTER_LIMIT_FAT12 < (sectors_per_cluster * bytes_per_sector)) {<br>
+        ret_val = EINVAL;<br>
+        finished = true;<br>
+      }<br>
+    } else if ((sectors_per_cluster * bytes_per_sector)<br>
        > MS_BYTES_PER_CLUSTER_LIMIT) {<br>
       ret_val = EINVAL;<br>
       finished = true;<br>
@@ -352,11 +384,9 @@ static int msdos_format_eval_sectors_per_cluster<br>
   if (ret_val != 0) {<br>
     rtems_set_errno_and_return_minus_one(ret_val);<br>
   }<br>
-  else {<br>
-    *sectors_per_cluster_adj = sectors_per_cluster;<br>
-    *sectors_per_fat_ptr     = sectors_per_fat;<br>
-    return 0;<br>
-  }<br>
+  *sectors_per_cluster_adj = sectors_per_cluster;<br>
+  *sectors_per_fat_ptr     = fat_sectors_cnt / fat_num;<br>
+  return 0;<br>
 }<br>
<br>
<br>
@@ -381,7 +411,6 @@ static int msdos_format_determine_fmt_params<br>
 \*=========================================================================*/<br>
 {<br>
   int ret_val = 0;<br>
-  uint32_t fatdata_sect_cnt;<br>
   uint32_t onebit;<br>
   uint32_t sectors_per_cluster_adj = 0;<br>
   uint64_t total_size = 0;<br>
@@ -393,7 +422,8 @@ static int msdos_format_determine_fmt_params<br>
    * At least one thing we don't have to magically guess...<br>
    */<br>
   if (ret_val == 0) {<br>
-    ret_val = rtems_disk_fd_get_block_size(fd, &fmt_params->bytes_per_sector);<br>
+    ret_val = rtems_disk_fd_get_media_block_size(fd, &fmt_params->bytes_per_sector);<br>
+<br>
   }<br>
   if (ret_val == 0) {<br>
     ret_val = rtems_disk_fd_get_block_count(fd, &fmt_params->totl_sector_cnt);<br>
@@ -410,7 +440,7 @@ static int msdos_format_determine_fmt_params<br>
    */<br>
   if (ret_val == 0) {<br>
     if ((rqdata == NULL) ||<br>
-       (rqdata->fat_num == 0)) {<br>
+             (rqdata->fat_num == 0)) {<br>
       fmt_params->fat_num = 2;<br>
     }<br>
     else if (rqdata->fat_num <= 6) {<br>
@@ -462,19 +492,19 @@ static int msdos_format_determine_fmt_params<br>
   if (ret_val == 0) {<br>
     fmt_params->sectors_per_cluster = 1;<br>
     if ((rqdata != NULL) &&<br>
-       (rqdata->fattype == MSDOS_FMT_FAT12)) {<br>
+             (rqdata->fattype == MSDOS_FMT_FAT12)) {<br>
       fmt_params->fattype = FAT_FAT12;<br>
     }<br>
     else if ((rqdata != NULL) &&<br>
-            (rqdata->fattype == MSDOS_FMT_FAT16)) {<br>
+                  (rqdata->fattype == MSDOS_FMT_FAT16)) {<br>
       fmt_params->fattype = FAT_FAT16;<br>
     }<br>
     else if ((rqdata != NULL) &&<br>
-            (rqdata->fattype == MSDOS_FMT_FAT32)) {<br>
+                  (rqdata->fattype == MSDOS_FMT_FAT32)) {<br>
       fmt_params->fattype = FAT_FAT32;<br>
     }<br>
     else if ((rqdata != NULL) &&<br>
-            (rqdata->fattype != MSDOS_FMT_FATANY)) {<br>
+                  (rqdata->fattype != MSDOS_FMT_FATANY)) {<br>
       ret_val = -1;<br>
       errno = EINVAL;<br>
     }<br>
@@ -492,14 +522,12 @@ static int msdos_format_determine_fmt_params<br>
         fat16_sect_per_clust = rqdata->sectors_per_cluster;<br>
       }<br>
<br>
-      if (fmt_params->totl_sector_cnt<br>
-          < FAT_FAT12_MAX_CLN * fat12_sect_per_clust) {<br>
+      if (fmt_params->totl_sector_cnt < FAT_FAT12_MAX_CLN * fat12_sect_per_clust) {<br>
         fmt_params->fattype = FAT_FAT12;<br>
         /* start trying with small clusters */<br>
         fmt_params->sectors_per_cluster = 2;<br>
       }<br>
-      else if (fmt_params->totl_sector_cnt<br>
-               < FAT_FAT16_MAX_CLN * fat16_sect_per_clust) {<br>
+      else if (fmt_params->totl_sector_cnt < FAT_FAT16_MAX_CLN * fat16_sect_per_clust) {<br>
         fmt_params->fattype = FAT_FAT16;<br>
         /* start trying with small clusters */<br>
         fmt_params->sectors_per_cluster = 2;<br>
@@ -520,9 +548,8 @@ static int msdos_format_determine_fmt_params<br>
      * try to use user requested cluster size<br>
      */<br>
     if ((rqdata != NULL) &&<br>
-       (rqdata->sectors_per_cluster > 0)) {<br>
-      fmt_params->sectors_per_cluster =<br>
-       rqdata->sectors_per_cluster;<br>
+             (rqdata->sectors_per_cluster > 0)) {<br>
+      fmt_params->sectors_per_cluster = rqdata->sectors_per_cluster;<br>
     }<br>
     /*<br>
      * check sectors per cluster.<br>
@@ -532,16 +559,22 @@ static int msdos_format_determine_fmt_params<br>
      */<br>
     for (onebit = 128;onebit >= 1;onebit = onebit>>1) {<br>
       if (fmt_params->sectors_per_cluster >= onebit) {<br>
-       fmt_params->sectors_per_cluster = onebit;<br>
-       if (fmt_params->sectors_per_cluster<br>
-           <= 32768L/fmt_params->bytes_per_sector) {<br>
-         /* value is small enough so this value is ok */<br>
-         onebit = 1;<br>
-       }<br>
+             fmt_params->sectors_per_cluster = onebit;<br>
+             if (fmt_params->sectors_per_cluster <= 32768L/fmt_params->bytes_per_sector) {<br>
+               /* value is small enough so this value is ok */<br>
+               onebit = 1;<br>
+             }<br>
       }<br>
     }<br>
   }<br>
<br>
+  /*<br>
+   * Skip aligning structures or d align them<br>
+   */<br>
+  if (   (0    == ret_val)<br>
+      && (NULL != rqdata)) {<br>
+    fmt_params->skip_alignment = rqdata->skip_alignment;<br>
+  }<br>
   if (ret_val == 0) {<br>
     msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL,<br>
                          "sectors per cluster: %d\n", fmt_params->sectors_per_cluster);<br>
@@ -564,34 +597,31 @@ static int msdos_format_determine_fmt_params<br>
       /* for FAT12/FAT16, set files per root directory */<br>
       /* must fill up an even count of sectors         */<br>
       if ((rqdata != NULL) &&<br>
-         (rqdata->files_per_root_dir > 0)) {<br>
-       fmt_params->files_per_root_dir = rqdata->files_per_root_dir;<br>
+               (rqdata->files_per_root_dir > 0)) {<br>
+             fmt_params->files_per_root_dir = rqdata->files_per_root_dir;<br>
       }<br>
       else {<br>
-       if (fmt_params->fattype == FAT_FAT16) {<br>
-         fmt_params->files_per_root_dir = 512;<br>
-       }<br>
-       else {<br>
-         fmt_params->files_per_root_dir = 64;<br>
-       }<br>
+             if (fmt_params->fattype == FAT_FAT16) {<br>
+               fmt_params->files_per_root_dir = 512;<br>
+             }<br>
+             else {<br>
+               fmt_params->files_per_root_dir = 64;<br>
+             }<br>
       }<br>
       fmt_params->files_per_root_dir = (fmt_params->files_per_root_dir +<br>
-                           (2*fmt_params->bytes_per_sector/<br>
-                            FAT_DIRENTRY_SIZE-1));<br>
+                                                        (2*fmt_params->bytes_per_sector/<br>
+                                                        FAT_DIRENTRY_SIZE-1));<br>
       fmt_params->files_per_root_dir -= (fmt_params->files_per_root_dir %<br>
-                            (2*fmt_params->bytes_per_sector<br>
-                             /FAT_DIRENTRY_SIZE));<br>
+                                                         (2*fmt_params->bytes_per_sector<br>
+                                                         /FAT_DIRENTRY_SIZE));<br>
+<br>
     }<br>
     fmt_params->root_dir_sectors =<br>
       (((fmt_params->files_per_root_dir * FAT_DIRENTRY_SIZE)<br>
-       + fmt_params->bytes_per_sector - 1)<br>
+             + fmt_params->bytes_per_sector - 1)<br>
        / fmt_params->bytes_per_sector);<br>
   }<br>
   if (ret_val == 0) {<br>
-    fatdata_sect_cnt = (fmt_params->totl_sector_cnt -<br>
-                       fmt_params->rsvd_sector_cnt -<br>
-                       fmt_params->root_dir_sectors);<br>
-<br>
     /*<br>
      * check values to get legal arrangement of FAT type and cluster count<br>
      */<br>
@@ -599,30 +629,45 @@ static int msdos_format_determine_fmt_params<br>
     ret_val = msdos_format_eval_sectors_per_cluster<br>
       (fmt_params->fattype,<br>
        fmt_params->bytes_per_sector,<br>
-       fatdata_sect_cnt,<br>
+       fmt_params->totl_sector_cnt,<br>
+       fmt_params->rsvd_sector_cnt,<br>
+       fmt_params->root_dir_sectors,<br>
        fmt_params->fat_num,<br>
        fmt_params->sectors_per_cluster,<br>
+       fmt_params->skip_alignment,<br>
        &sectors_per_cluster_adj,<br>
        &(fmt_params->sectors_per_fat));<br>
     fmt_params->sectors_per_cluster = sectors_per_cluster_adj;<br>
   }<br>
+  if (0 == ret_val)<br>
+  {<br>
+    if (FAT_FAT32 != fmt_params->fattype)<br>
+    {<br>
+      fmt_params->files_per_root_dir = loc_align_object (fmt_params->root_dir_sectors,<br>
+                                                         fmt_params->sectors_per_cluster,<br>
+                                                         fmt_params->skip_alignment)<br>
+                                       * (fmt_params->bytes_per_sector >> 5);<br>
+    }<br>
+    fmt_params->rsvd_sector_cnt = loc_align_object (fmt_params->rsvd_sector_cnt,<br>
+                                                    fmt_params->sectors_per_cluster,<br>
+                                                    fmt_params->skip_alignment);<br>
+  }<br>
<br>
   /*<br>
    * determine media code<br>
    */<br>
   if (ret_val == 0) {<br>
-    if ((rqdata != NULL) &&<br>
-       (rqdata->media != 0)) {<br>
+    if ((rqdata != NULL) && (rqdata->media != 0)) {<br>
       const char valid_media_codes[] =<br>
-       {0xF0,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF};<br>
+             {0xF0,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF};<br>
       if (NULL==memchr(valid_media_codes,<br>
                       rqdata->media,<br>
                       sizeof(valid_media_codes))) {<br>
-       ret_val = -1;<br>
-       errno = EINVAL;<br>
+             ret_val = -1;<br>
+             errno = EINVAL;<br>
       }<br>
       else {<br>
-       fmt_params->media_code = rqdata->media;<br>
+             fmt_params->media_code = rqdata->media;<br>
       }<br>
     }<br>
     else {<br>
@@ -636,7 +681,7 @@ static int msdos_format_determine_fmt_params<br>
   if (fmt_params->root_dir_sectors > 0) {<br>
     fmt_params->root_dir_start_sec =<br>
       fmt_params->rsvd_sector_cnt<br>
-      + (fmt_params-> fat_num*fmt_params->sectors_per_fat);<br>
+      + (fmt_params->fat_num*fmt_params->sectors_per_fat);<br>
     fmt_params->root_dir_fmt_sec_cnt = fmt_params->root_dir_sectors;<br>
   }<br>
   else {<br>
@@ -648,6 +693,8 @@ static int msdos_format_determine_fmt_params<br>
       + (fmt_params-> fat_num*fmt_params->sectors_per_fat);<br>
     fmt_params->root_dir_fmt_sec_cnt = fmt_params->sectors_per_cluster;<br>
   }<br>
+<br>
+<br></blockquote><div>Only one blank line<br> <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
   /*<br>
    * determine usable OEMName<br>
    */<br>
@@ -656,23 +703,20 @@ static int msdos_format_determine_fmt_params<br>
       char        *to = fmt_params->OEMName;<br>
       int          cnt;<br>
       from = "RTEMS"; /* default: make "from" point to OS Name */<br>
-    if ((rqdata != NULL) &&<br>
-       (rqdata->OEMName != NULL)) {<br>
+    if ((rqdata != NULL) && (rqdata->OEMName != NULL)) {<br>
       from = rqdata->OEMName;<br>
     }<br>
-    for (cnt = 0;<br>
-        cnt < (sizeof(fmt_params->OEMName)-1);<br>
-        cnt++) {<br>
+    for (cnt = 0; cnt < (sizeof(fmt_params->OEMName)-1); cnt++) {<br>
       if (isprint((unsigned char)*from)) {<br>
-       *to++ = *from++;<br>
+             *to++ = *from++;<br>
       }<br>
       else {<br>
-       /*<br>
-        * non-printable character in given name, so keep stuck<br>
-        * at that character and replace all following characters<br>
-        * with a ' '<br>
-        */<br>
-       *to++=' ';<br>
+        /*<br>
+         * non-printable character in given name, so keep stuck<br>
+         * at that character and replace all following characters<br>
+         * with a ' '<br>
+         */<br>
+        *to++=' ';<br>
       }<br>
       *to = '\0';<br>
     }<br>
@@ -686,24 +730,21 @@ static int msdos_format_determine_fmt_params<br>
       char        *to = fmt_params->VolLabel;<br>
       int          cnt;<br>
       from = ""; /* default: make "from" point to empty string */<br>
-    if ((rqdata != NULL) &&<br>
-       (rqdata->VolLabel != NULL)) {<br>
+    if ((rqdata != NULL) &&    (rqdata->VolLabel != NULL)) {<br>
       from = rqdata->VolLabel;<br>
       fmt_params->VolLabel_present = true;<br>
     }<br>
-    for (cnt = 0;<br>
-        cnt < (sizeof(fmt_params->VolLabel)-1);<br>
-        cnt++) {<br>
+    for (cnt = 0;      cnt < (sizeof(fmt_params->VolLabel)-1); cnt++) {<br>
       if (isprint((unsigned char)*from)) {<br>
-       *to++ = *from++;<br>
+             *to++ = *from++;<br></blockquote><div>Nesting level should be just two blank space characters, not 8.<br><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

       }<br>
       else {<br>
-       /*<br>
-        * non-printable character in given name, so keep stuck<br>
-        * at that character and replace all following characters<br>
-        * with a ' '<br>
-        */<br>
-       *to++=' ';<br>
+        /*<br>
+         * non-printable character in given name, so keep stuck<br>
+         * at that character and replace all following characters<br>
+         * with a ' '<br>
+         */<br>
+        *to++=' ';<br>
       }<br>
       *to = '\0';<br>
     }<br>
@@ -721,9 +762,7 @@ static int msdos_format_determine_fmt_params<br>
   if (ret_val != 0) {<br>
     rtems_set_errno_and_return_minus_one(ret_val);<br>
   }<br>
-  else {<br>
-    return 0;<br>
-  }<br>
+  return 0;<br>
 }<br>
 /*=========================================================================*\<br>
 | Function:                                                                 |<br>
@@ -1106,15 +1145,14 @@ int msdos_format<br>
        */<br>
       FAT_SET_VAL32(tmp_sec,8,FAT_FAT32_EOC);<br>
     }<br>
-    for (i = 0;<br>
-        (i < fmt_params.fat_num) && (ret_val == 0);<br>
-        i++) {<br>
+    unsigned int start_sector = loc_align_object (fmt_params.rsvd_sector_cnt, fmt_params.sectors_per_cluster, fmt_params.skip_alignment);<br>
+    for (i = 0; (i < fmt_params.fat_num) && (ret_val == 0); i++) {<br>
       ret_val = msdos_format_write_sec<br>
-       (fd,<br>
-        fmt_params.rsvd_sector_cnt<br>
-        + (i * fmt_params.sectors_per_fat),<br>
-        fmt_params.bytes_per_sector,<br>
-        tmp_sec);<br>
+          (fd,<br>
+           start_sector<br>
+           + (i * fmt_params.sectors_per_fat),<br>
+           fmt_params.bytes_per_sector,<br>
+           tmp_sec);<br>
     }<br>
   }<br>
   /*<br>
@@ -1126,5 +1164,8 @@ int msdos_format<br>
     close(fd);<br>
   }<br>
<br>
-  return ret_val;<br>
+  if (0 != ret_val)<br>
+    return -1;<br>
+  else<br>
+    return 0;<br>
 }<br>
diff --git a/cpukit/libmisc/shell/main_msdosfmt.c b/cpukit/libmisc/shell/main_msdosfmt.c<br>
index 47dd9f1..60926b9 100644<br>
--- a/cpukit/libmisc/shell/main_msdosfmt.c<br>
+++ b/cpukit/libmisc/shell/main_msdosfmt.c<br>
@@ -36,7 +36,7 @@ static int rtems_shell_main_msdos_format(<br>
     .fattype =             MSDOS_FMT_FATANY,<br>
     .media =               0,<br>
     .quick_format =        TRUE,<br>
-    .cluster_align =       0,<br>
+    .skip_alignment =      0,<br>
     .info_level =          0<br>
   };<br>
<br>
@@ -149,7 +149,7 @@ static int rtems_shell_main_msdos_format(<br>
     printf (" %-20s: %i\n", "fat type", rqdata.fattype);<br>
     printf (" %-20s: %d\n", "media", rqdata.media);<br>
     printf (" %-20s: %d\n", "quick_format", rqdata.quick_format);<br>
-    printf (" %-20s: %" PRIu32 "\n", "cluster align", rqdata.cluster_align);<br>
+    printf (" %-20s: %s\n", "skip_alignment", (0 == rqdata.skip_alignment) ? "false" : "true");<br>
   }<br>
<br>
   if (msdos_format (driver, &rqdata) < 0) {<br>
diff --git a/testsuites/fstests/mdosfs_support/fs_support.c b/testsuites/fstests/mdosfs_support/fs_support.c<br>
index ef4356e..c58379a 100644<br>
--- a/testsuites/fstests/mdosfs_support/fs_support.c<br>
+++ b/testsuites/fstests/mdosfs_support/fs_support.c<br>
@@ -34,7 +34,7 @@ msdos_format_request_param_t rqdata = {<br>
     fattype:             MSDOS_FMT_FATANY,<br>
     media:               0,<br>
     quick_format:        FALSE,<br>
-    cluster_align:       0,<br>
+    skip_alignment:      0,<br>
     info_level:          0<br>
 };<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.7.10.4<br>
<br>
_______________________________________________<br>
rtems-devel mailing list<br>
<a href="mailto:rtems-devel@rtems.org">rtems-devel@rtems.org</a><br>
<a href="http://www.rtems.org/mailman/listinfo/rtems-devel" target="_blank">http://www.rtems.org/mailman/listinfo/rtems-devel</a><br>
</font></span></blockquote></div><br></div>