source: rtems/cpukit/libfs/src/rfs/rtems-rfs-format.c @ a9fa9b7

4.104.11
Last change on this file since a9fa9b7 was a9fa9b7, checked in by Chris Johns <chrisj@…>, on Feb 18, 2010 at 12:24:25 AM

2010-02-18 Chris Johns <chrisj@…>

  • libfs/src/rfs/rtems-rfs-bitmaps.c, libfs/src/rfs/rtems-rfs-bitmaps.h, libfs/src/rfs/rtems-rfs-bitmaps-ut.c, libfs/src/rfs/rtems-rfs-block.c, libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-block-pos.h, libfs/src/rfs/rtems-rfs-buffer-bdbuf.c, libfs/src/rfs/rtems-rfs-buffer.c, libfs/src/rfs/rtems-rfs-buffer-devio.c, libfs/src/rfs/rtems-rfs-buffer.h, libfs/src/rfs/rtems-rfs-data.h, libfs/src/rfs/rtems-rfs-dir.c, libfs/src/rfs/rtems-rfs-dir.h, libfs/src/rfs/rtems-rfs-dir-hash.c, libfs/src/rfs/rtems-rfs-dir-hash.h, libfs/src/rfs/rtems-rfs-file.c, libfs/src/rfs/rtems-rfs-file.h, libfs/src/rfs/rtems-rfs-file-system.c, libfs/src/rfs/rtems-rfs-file-system-fwd.h, libfs/src/rfs/rtems-rfs-file-system.h, libfs/src/rfs/rtems-rfs-format.c, libfs/src/rfs/rtems-rfs-format.h, libfs/src/rfs/rtems-rfs-group.c, libfs/src/rfs/rtems-rfs-group.h, libfs/src/rfs/rtems-rfs.h, libfs/src/rfs/rtems-rfs-inode.c, libfs/src/rfs/rtems-rfs-inode.h, libfs/src/rfs/rtems-rfs-link.c, libfs/src/rfs/rtems-rfs-link.h, libfs/src/rfs/rtems-rfs-mutex.c, libfs/src/rfs/rtems-rfs-mutex.h, libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems-dev.c, libfs/src/rfs/rtems-rfs-rtems-dir.c, libfs/src/rfs/rtems-rfs-rtems-file.c, libfs/src/rfs/rtems-rfs-rtems.h, libfs/src/rfs/rtems-rfs-rtems-utils.c, libfs/src/rfs/rtems-rfs-shell.c, libfs/src/rfs/rtems-rfs-shell.h, libfs/src/rfs/rtems-rfs-trace.c, libfs/src/rfs/rtems-rfs-trace.h: New.
  • Makefile.am, preinstall.am, libfs/Makefile.am, wrapup/Makefile.am: Updated with the RFS support.
  • libfs/README: Updated after 10 years.
  • libblock/src/flashdisk.c, libblock/src/nvdisk.c, libblock/src/ramdisk-driver.c: Updated to the new error reporting in libblock.
  • libmisc/shell/main_ls.c, libmisc/shell/print-ls.c: Fix printing the size in long mode.
  • libnetworking/nfs/bootp_subr.c, libnetworking/rtems/rtems_bootp.c, libnetworking/rtems/rtems_bsdnet_internal.h: Return the BOOTP/DHCP to the forever behaviour of 4.9 with the ability to call BOOTP and control the process if required.
  • Property mode set to 100644
File size: 17.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 *  $Id$
9 */
10/**
11 * @file
12 *
13 * @ingroup rtems-rfs
14 *
15 * RTEMS File Systems Format
16 *
17 * Format the file system ready for use.
18 */
19
20#include <stdlib.h>
21#include <stdio.h>
22
23#include <rtems/rfs/rtems-rfs-data.h>
24#include <rtems/rfs/rtems-rfs-file-system.h>
25#include <rtems/rfs/rtems-rfs-inode.h>
26#include <rtems/rtems-rfs-format.h>
27#include <rtems/rfs/rtems-rfs-dir.h>
28
29/**
30 * Return the number of gigabytes.
31 */
32#define GIGS(_g) ((_g) * 1024 * 1024)
33
34/**
35 * Return the number of bits that fit in the block size.
36 */
37static int
38rtems_rfs_bits_per_block (rtems_rfs_file_system* fs)
39{
40  return rtems_rfs_bitmap_numof_bits (rtems_rfs_fs_block_size (fs));
41}
42
43/**
44 * Return a rounded up integer quotient given a dividend and divisor. That is:
45 * "quotient = dividend / divisor"
46 */
47int
48rtems_rfs_rup_quotient (uint32_t dividend, uint32_t divisor)
49{
50  if (dividend == 0)
51    return 1;
52  return ((dividend - 1) / divisor) + 1;
53}
54
55/**
56 * Return the number of inodes as a percentage of the total number that can fit
57 * in a blocl.
58 */
59static int
60rtems_rfs_inodes_from_percent (rtems_rfs_file_system* fs,
61                               int                    percentage)
62{
63  int blocks;
64  blocks = (rtems_rfs_bits_per_block (fs) * percentage) / 100;
65  return blocks * (rtems_rfs_fs_block_size (fs) / sizeof (rtems_rfs_inode));
66}
67
68/**
69 * Return the inode overhead given a number of inodes.
70 */
71static int
72rtems_rfs_inode_overhead (rtems_rfs_file_system* fs)
73{
74  int blocks;
75  blocks =
76    (fs->group_inodes * sizeof (rtems_rfs_inode)) / rtems_rfs_fs_block_size (fs);
77  return ((blocks + 1) * 100 * 10) / rtems_rfs_bits_per_block (fs);
78}
79
80static bool
81rtems_rfs_check_config (rtems_rfs_file_system*         fs,
82                        const rtems_rfs_format_config* config)
83{
84  fs->block_size = config->block_size;
85  if (!fs->block_size)
86  {
87    uint64_t total_size = rtems_rfs_fs_media_size (fs);
88
89    if (total_size > GIGS (2))
90    {
91      uint32_t gigs = (total_size + GIGS (1)) / GIGS (1);
92      int      b;
93      for (b = 31; b > 0; b--)
94        if ((gigs & (1 << b)) != 0)
95          break;
96      fs->block_size = 1 << b;
97    }
98
99    if (fs->block_size < 1024)
100      fs->block_size = 1024;
101   
102    if (fs->block_size > (4 * 1024))
103      fs->block_size = (4 * 1024);
104  }
105 
106  if ((fs->block_size % rtems_rfs_fs_media_block_size (fs)) != 0)
107  {
108    printf ("block size (%ld) is not a multiple of media block size (%ld)\n",
109            fs->block_size, rtems_rfs_fs_media_block_size (fs));
110    return false;
111  }
112
113  fs->group_blocks = config->group_blocks;
114  if (!fs->group_blocks)
115  {
116    /*
117     * The number of blocks per group is defined by the number of bits in a
118     * block.
119     */
120    fs->group_blocks = rtems_rfs_bitmap_numof_bits (fs->block_size);
121  }
122
123  if (fs->group_blocks > rtems_rfs_bitmap_numof_bits (fs->block_size))
124  {
125    printf ("group block count is higher than bits in block\n");
126    return false;
127  }
128 
129  fs->group_inodes = config->group_inodes;
130  if (!fs->group_inodes)
131  {
132    int inode_overhead = RTEMS_RFS_INODE_OVERHEAD_PERCENTAGE;
133   
134    /*
135     * The number of inodes per group is set as a percentage.
136     */
137    if (config->inode_overhead)
138      inode_overhead = config->inode_overhead;
139     
140    fs->group_inodes = rtems_rfs_inodes_from_percent (fs, inode_overhead);
141  }
142
143  /*
144   * Round up to fill a block because the minimum allocation unit is a block.
145   */
146  fs->inodes_per_block = rtems_rfs_fs_block_size (fs) / sizeof (rtems_rfs_inode);
147  fs->group_inodes =
148    rtems_rfs_rup_quotient (fs->group_inodes,
149                            fs->inodes_per_block) * fs->inodes_per_block;
150 
151  if (fs->group_inodes > rtems_rfs_bitmap_numof_bits (fs->block_size))
152    fs->group_inodes = rtems_rfs_bitmap_numof_bits (fs->block_size);
153
154  fs->max_name_length = config->max_name_length;
155  if (!fs->max_name_length)
156  {
157    fs->max_name_length = 512;
158  }
159 
160  return true;
161}
162
163static bool
164rtems_rfs_write_group (rtems_rfs_file_system* fs,
165                       int                    group,
166                       bool                   initialise_inodes,
167                       bool                   verbose)
168{
169  rtems_rfs_buffer_handle  handle;
170  rtems_rfs_bitmap_control bitmap;
171  rtems_rfs_buffer_block   group_base;
172  size_t                   group_size;
173  int                      blocks;
174  int                      b;
175  int                      rc;
176 
177  group_base = rtems_rfs_fs_block (fs, group, 0);
178
179  if (group_base > rtems_rfs_fs_blocks (fs))
180  {
181    printf ("rtems-rfs: write-group: group %d base beyond disk limit\n",
182            group);
183    return false;
184  }
185
186  group_size = fs->group_blocks;
187
188  /*
189   * Be nice to strange sizes of disks. These are embedded systems after all
190   * and nice numbers do not always work out. Let the last block pick up the
191   * remainder of the blocks.
192   */
193  if ((group_base + group_size) > rtems_rfs_fs_blocks (fs))
194    group_size = rtems_rfs_fs_blocks (fs) - group_base;
195
196  if (verbose)
197    printf ("\rrtems-rfs: format: group %3d: base = %ld, size = %ld",
198            group, group_base, group_size);
199
200  /*
201   * Open a handle and request an empty buffer.
202   */
203  rc = rtems_rfs_buffer_handle_open (fs, &handle);
204  if (rc > 0)
205  {
206    printf ("\nrtems-rfs: write-group: handle open failed: %d: %s\n",
207            rc, strerror (rc));
208    return false;
209  }
210
211  if (verbose)
212    printf (", blocks");
213 
214  /*
215   * Open the block bitmap using the new buffer.
216   */
217  rc = rtems_rfs_bitmap_open (&bitmap, fs, &handle, group_size,
218                              group_base + RTEMS_RFS_GROUP_BLOCK_BITMAP_BLOCK);
219  if (rc > 0)
220  {
221    rtems_rfs_buffer_handle_close (fs, &handle);
222    printf ("\nrtems-rfs: write-group: group %3d: open block bitmap failed: %d: %s\n",
223            group, rc, strerror (rc));
224    return false;
225  }
226
227  /*
228   * Force the whole buffer to a known state. The bit map may not occupy the
229   * whole block.
230   */
231  memset (rtems_rfs_buffer_data (&handle), 0xff, rtems_rfs_fs_block_size (fs));
232 
233  /*
234   * Clear the bitmap.
235   */
236  rc = rtems_rfs_bitmap_map_clear_all (&bitmap);
237  if (rc > 0)
238  {
239    rtems_rfs_bitmap_close (&bitmap);
240    rtems_rfs_buffer_handle_close (fs, &handle);
241    printf ("\nrtems-rfs: write-group: group %3d: block bitmap clear all failed: %d: %s\n",
242            group, rc, strerror (rc));
243    return false;
244  }
245 
246  /*
247   * Forced allocation of the block bitmap.
248   */
249  rtems_rfs_bitmap_map_set (&bitmap, RTEMS_RFS_GROUP_BLOCK_BITMAP_BLOCK);
250
251  /*
252   * Forced allocation of the inode bitmap.
253   */
254  rtems_rfs_bitmap_map_set (&bitmap, RTEMS_RFS_GROUP_INODE_BITMAP_BLOCK);
255
256  /*
257   * Determine the number of inodes blocks in the group.
258   */
259  blocks = rtems_rfs_rup_quotient (fs->group_inodes, fs->inodes_per_block);
260
261  /*
262   * Forced allocation of the inode blocks which follow the block bitmap.
263   */
264  for (b = 0; b < blocks; b++)
265    rtems_rfs_bitmap_map_set (&bitmap, b + RTEMS_RFS_GROUP_INODE_BLOCK);
266
267  /*
268   * Close the block bitmap.
269   */
270  rc = rtems_rfs_bitmap_close (&bitmap);
271  if (rc > 0)
272  {
273    rtems_rfs_buffer_handle_close (fs, &handle);
274    printf ("\nrtems-rfs: write-group: group %3d: close block bitmap failed: %d: %s\n",
275            group, rc, strerror (rc));
276    return false;
277  }
278
279  rtems_rfs_buffer_mark_dirty (&handle);
280
281  if (verbose)
282    printf (", inodes");
283 
284  /*
285   * Open the inode bitmap using the old buffer. Should release any changes.
286   */
287  rc = rtems_rfs_bitmap_open (&bitmap, fs, &handle, group_size,
288                              group_base + RTEMS_RFS_GROUP_INODE_BITMAP_BLOCK);
289  if (rc > 0)
290  {
291    rtems_rfs_buffer_handle_close (fs, &handle);
292    printf ("\nrtems-rfs: write-group: group %3d: open inode bitmap failed: %d: %s\n",
293            group, rc, strerror (rc));
294    return false;
295  }
296
297  /*
298   * Force the whole buffer to a known state. The bit map may not occupy the
299   * whole block.
300   */
301  memset (rtems_rfs_buffer_data (&handle), 0x00, rtems_rfs_fs_block_size (fs));
302 
303  /*
304   * Clear the inode bitmap.
305   */
306  rc = rtems_rfs_bitmap_map_clear_all (&bitmap);
307  if (rc > 0)
308  {
309    rtems_rfs_bitmap_close (&bitmap);
310    rtems_rfs_buffer_handle_close (fs, &handle);
311    printf ("\nrtems-rfs: write-group: group %3d: inode bitmap" \
312            " clear all failed: %d: %s\n", group, rc, strerror (rc));
313    return false;
314  }
315 
316  /*
317   * Close the inode bitmap.
318   */
319  rc = rtems_rfs_bitmap_close (&bitmap);
320  if (rc > 0)
321  {
322    rtems_rfs_buffer_handle_close (fs, &handle);
323    printf ("\nrtems-rfs: write-group: group %3d: close inode" \
324            " bitmap failed: %d: %s\n", group, rc, strerror (rc));
325    return false;
326  }
327
328  rtems_rfs_buffer_mark_dirty (&handle);
329
330  /*
331   * Initialise the inode tables if rerquired to do so.
332   */
333  if (initialise_inodes)
334  {
335    for (b = 0; b < blocks; b++)
336    {
337      rc = rtems_rfs_buffer_handle_request (fs, &handle,
338                                            group_base + b + RTEMS_RFS_GROUP_INODE_BLOCK,
339                                            false);
340      if (rc > 0)
341      {
342        rtems_rfs_buffer_handle_close (fs, &handle);
343        printf ("\nrtems-rfs: write-group: group %3d: block %ld request failed: %d: %s\n",
344                group, group_base + b + RTEMS_RFS_GROUP_INODE_BLOCK,
345                rc, strerror (rc));
346        return false;
347      }
348   
349      /*
350       * Force the whole buffer to a known state. The bit map may not occupy the
351       * whole block.
352       */
353      memset (rtems_rfs_buffer_data (&handle), 0xff, rtems_rfs_fs_block_size (fs));
354 
355      rtems_rfs_buffer_mark_dirty (&handle);
356    }
357  }
358 
359  rc = rtems_rfs_buffer_handle_close (fs, &handle);
360  if (rc > 0)
361  {
362    printf ("\nrtems-rfs: write-group: buffer handle close failed: %d: %s\n",
363            rc, strerror (rc));
364    return false;
365  }
366 
367  return true;
368}
369
370static bool
371rtems_rfs_write_superblock (rtems_rfs_file_system* fs)
372{
373  rtems_rfs_buffer_handle handle;
374  uint8_t*                sb;
375  int                     rc;
376
377  rc = rtems_rfs_buffer_handle_open (fs, &handle);
378  if (rc > 0)
379  {
380    printf ("rtems-rfs: write-superblock: handle open failed: %d: %s\n",
381            rc, strerror (rc));
382    return false;
383  }
384
385  rc = rtems_rfs_buffer_handle_request (fs, &handle, 0, false);
386  if (rc > 0)
387  {
388    rtems_rfs_buffer_handle_close (fs, &handle);
389    printf ("rtems-rfs: write-superblock: request failed: %d: %s\n",
390            rc, strerror (rc));
391    return false;
392  }
393
394  sb = rtems_rfs_buffer_data (&handle);
395 
396#define write_sb(_o, _d) rtems_rfs_write_u32(sb + (_o), _d)
397 
398  memset (sb, 0xff, rtems_rfs_fs_block_size (fs));
399
400  write_sb (RTEMS_RFS_SB_OFFSET_MAGIC, RTEMS_RFS_SB_MAGIC);
401  write_sb (RTEMS_RFS_SB_OFFSET_BLOCKS, rtems_rfs_fs_blocks (fs));
402  write_sb (RTEMS_RFS_SB_OFFSET_BLOCK_SIZE, rtems_rfs_fs_block_size (fs));
403  write_sb (RTEMS_RFS_SB_OFFSET_BAD_BLOCKS, fs->bad_blocks);
404  write_sb (RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH, fs->max_name_length);
405  write_sb (RTEMS_RFS_SB_OFFSET_GROUPS, fs->group_count);
406  write_sb (RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS, fs->group_blocks);
407  write_sb (RTEMS_RFS_SB_OFFSET_GROUP_INODES, fs->group_inodes);
408
409  rtems_rfs_buffer_mark_dirty (&handle);
410
411  rc = rtems_rfs_buffer_handle_release (fs, &handle);
412  if (rc > 0)
413  {
414    rtems_rfs_buffer_handle_close (fs, &handle);
415    printf ("rtems-rfs: write-superblock: buffer release failed: %d: %s\n",
416            rc, strerror (rc));
417    return false;
418  }
419
420  rc = rtems_rfs_buffer_handle_close (fs, &handle);
421  if (rc > 0)
422  {
423    printf ("rtems-rfs: write-superblock: buffer handle close failed: %d: %s\n",
424            rc, strerror (rc));
425    return false;
426  }
427 
428  return true;
429}
430
431static int
432rtems_rfs_write_root_dir (const char* name)
433{
434  rtems_rfs_file_system* fs;
435  rtems_rfs_inode_handle inode;
436  rtems_rfs_ino          ino;
437  int                    rc;
438
439  /*
440   * External API so returns -1.
441   */
442  rc = rtems_rfs_fs_open (name, NULL, RTEMS_RFS_FS_FORCE_OPEN, &fs);
443  if (rc < 0)
444  {
445    printf ("rtems-rfs: format: file system open failed: %d: %s\n",
446            errno, strerror (errno));
447    return -1;
448  }
449 
450  rc = rtems_rfs_inode_alloc (fs, RTEMS_RFS_ROOT_INO, &ino);
451  if (rc > 0)
452  {
453    printf ("rtems-rfs: format: inode allocation failed: %d: %s\n",
454            rc, strerror (rc));
455    rtems_rfs_fs_close (fs);
456    return rc;
457  }
458
459  if (ino != RTEMS_RFS_ROOT_INO)
460  {
461    printf ("rtems-rfs: format: allocated inode not root ino: %ld\n", ino);
462    rtems_rfs_fs_close (fs);
463    return rc;
464  }
465 
466  rc = rtems_rfs_inode_open (fs, ino, &inode, true);
467  if (rc > 0)
468  {
469    printf ("rtems-rfs: format: inode open failed: %d: %s\n",
470            rc, strerror (rc));
471    rtems_rfs_group_bitmap_free (fs, true, ino);
472    rtems_rfs_fs_close (fs);
473    return rc;
474  }
475
476  rc = rtems_rfs_inode_initialise (&inode, 0,
477                                   (RTEMS_RFS_S_IFDIR | RTEMS_RFS_S_IRWXU |
478                                    RTEMS_RFS_S_IXGRP | RTEMS_RFS_S_IXOTH),
479                                   0, 0);
480  if (rc > 0)
481    printf ("rtems-rfs: format: inode initialise failed: %d: %s\n",
482            rc, strerror (rc));
483 
484  rc = rtems_rfs_dir_add_entry (fs, &inode, ".", 1, ino);
485  if (rc > 0)
486    printf ("rtems-rfs: format: directory add failed: %d: %s\n",
487            rc, strerror (rc));
488 
489  rc = rtems_rfs_inode_close (fs, &inode);
490  if (rc > 0)
491    printf ("rtems-rfs: format: inode close failed: %d: %s\n",
492            rc, strerror (rc));
493 
494  rc = rtems_rfs_fs_close (fs);
495  if (rc < 0)
496    printf ("rtems-rfs: format: file system close failed: %d: %s\n",
497            errno, strerror (errno));
498 
499  return rc;
500}
501
502int
503rtems_rfs_format (const char* name, const rtems_rfs_format_config* config)
504{
505  rtems_rfs_file_system fs;
506  int                   group;
507  int                   rc;
508
509  if (config->verbose)
510    printf ("rtems-rfs: format: %s\n", name);
511 
512  memset (&fs, 0, sizeof (rtems_rfs_file_system));
513
514  rtems_chain_initialize_empty (&fs.release);
515  rtems_chain_initialize_empty (&fs.release_modified);
516  rtems_chain_initialize_empty (&fs.file_shares);
517
518  fs.max_held_buffers = RTEMS_RFS_FS_MAX_HELD_BUFFERS;
519
520  fs.release_count = 0;
521  fs.release_modified_count = 0;
522
523  fs.flags = RTEMS_RFS_FS_NO_LOCAL_CACHE;
524 
525  /*
526   * Open the buffer interface.
527   */
528  rc = rtems_rfs_buffer_open (name, &fs);
529  if (rc > 0)
530  {
531    printf ("rtems-rfs: format: buffer open failed: %d: %s\n",
532            rc, strerror (rc));
533    return -1;
534  }
535
536  /*
537   * Check the media.
538   */
539  if (rtems_rfs_fs_media_block_size (&fs) == 0)
540  {
541    printf ("rtems-rfs: media block is invalid: %lu\n",
542            rtems_rfs_fs_media_block_size (&fs));
543    return -1;
544  }
545 
546  /*
547   * Check the configuration data.
548   */
549  if (!rtems_rfs_check_config (&fs, config))
550    return -1;
551
552  fs.blocks = rtems_rfs_fs_media_size (&fs) / fs.block_size;
553
554  /*
555   * The bits per block sets the upper limit for the number of blocks in a
556   * group. The disk will be divided into groups which are the number of bits
557   * per block.
558   */ 
559  fs.group_count =
560    ((rtems_rfs_fs_blocks (&fs) - 1) / rtems_rfs_bits_per_block (&fs)) + 1;
561
562  if (config->verbose)
563  {
564    printf ("rtems-rfs: format: media size = %llu\n",
565            rtems_rfs_fs_media_size (&fs));
566    printf ("rtems-rfs: format: media blocks = %ld\n",
567            rtems_rfs_fs_media_blocks (&fs));
568    printf ("rtems-rfs: format: media block size = %lu\n",
569            rtems_rfs_fs_media_block_size (&fs));
570    printf ("rtems-rfs: format: size = %llu\n",
571            rtems_rfs_fs_size (&fs));
572    printf ("rtems-rfs: format: blocks = %lu\n",
573            rtems_rfs_fs_blocks (&fs));
574    printf ("rtems-rfs: format: block size = %lu\n",
575            rtems_rfs_fs_block_size (&fs));
576    printf ("rtems-rfs: format: bits per block = %u\n",
577            rtems_rfs_bits_per_block (&fs));
578    printf ("rtems-rfs: format: inode size = %lu\n", sizeof (rtems_rfs_inode));
579    printf ("rtems-rfs: format: inodes = %lu (%d.%d%%)\n",
580            fs.group_inodes * fs.group_count,
581            rtems_rfs_inode_overhead (&fs) / 10,
582            rtems_rfs_inode_overhead (&fs) % 10);
583    printf ("rtems-rfs: format: groups = %u\n", fs.group_count);
584    printf ("rtems-rfs: format: group blocks = %lu\n", fs.group_blocks);
585    printf ("rtems-rfs: format: group inodes = %lu\n", fs.group_inodes);
586  }
587
588  rc = rtems_rfs_buffer_setblksize (&fs, rtems_rfs_fs_block_size (&fs));
589  if (rc > 0)
590  {
591    printf ("rtems-rfs: format: setting block size failed: %d: %s\n",
592            rc, strerror (rc));
593    return -1;
594  }
595 
596  if (!rtems_rfs_write_superblock (&fs))
597  {
598    printf ("rtems-rfs: format: superblock write failed\n");
599    return -1;
600  }
601
602  for (group = 0; group < fs.group_count; group++)
603    if (!rtems_rfs_write_group (&fs, group,
604                                config->initialise_inodes, config->verbose))
605      return -1;
606
607  if (config->verbose)
608    printf ("\n");
609 
610  rc = rtems_rfs_buffer_close (&fs);
611  if (rc > 0)
612  {
613    printf ("rtems-rfs: format: buffer close failed: %d: %s\n",
614            rc, strerror (rc));
615    return -1;
616  }
617
618  rc = rtems_rfs_write_root_dir (name);
619  if (rc > 0)
620  {
621    printf ("rtems-rfs: format: writing root dir failed: %d: %s\n",
622            rc, strerror (rc));
623    return -1;
624  }
625 
626  return 0;
627}
Note: See TracBrowser for help on using the repository browser.