Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/util-linux/mkfs_minix.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 2  Line 2 
2  /*  /*
3   * mkfs.c - make a linux (minix) file-system.   * mkfs.c - make a linux (minix) file-system.
4   *   *
5   * (C) 1991 Linus Torvalds. This file may be redistributed as per   * (C) 1991 Linus Torvalds.
6   * the Linux copyright.   *
7     * Licensed under GPLv2, see file LICENSE in this tarball for details.
8   */   */
9    
10  /*  /*
# Line 160  static ALWAYS_INLINE unsigned div_roundu Line 161  static ALWAYS_INLINE unsigned div_roundu
161    
162  static int minix_bit(const char* a, unsigned i)  static int minix_bit(const char* a, unsigned i)
163  {  {
164    return a[i >> 3] & (1<<(i & 7));   return a[i >> 3] & (1<<(i & 7));
165  }  }
166    
167  static void minix_setbit(char *a, unsigned i)  static void minix_setbit(char *a, unsigned i)
# Line 242  static void write_tables(void) Line 243  static void write_tables(void)
243   msg_eol = "seek to 0 failed";   msg_eol = "seek to 0 failed";
244   xlseek(dev_fd, 0, SEEK_SET);   xlseek(dev_fd, 0, SEEK_SET);
245    
246   msg_eol = "cannot clear boot sector";   msg_eol = "can't clear boot sector";
247   xwrite(dev_fd, G.boot_block_buffer, 512);   xwrite(dev_fd, G.boot_block_buffer, 512);
248    
249   msg_eol = "seek to BLOCK_SIZE failed";   msg_eol = "seek to BLOCK_SIZE failed";
250   xlseek(dev_fd, BLOCK_SIZE, SEEK_SET);   xlseek(dev_fd, BLOCK_SIZE, SEEK_SET);
251    
252   msg_eol = "cannot write superblock";   msg_eol = "can't write superblock";
253   xwrite(dev_fd, G.superblock_buffer, BLOCK_SIZE);   xwrite(dev_fd, G.superblock_buffer, BLOCK_SIZE);
254    
255   msg_eol = "cannot write inode map";   msg_eol = "can't write inode map";
256   xwrite(dev_fd, G.inode_map, SB_IMAPS * BLOCK_SIZE);   xwrite(dev_fd, G.inode_map, SB_IMAPS * BLOCK_SIZE);
257    
258   msg_eol = "cannot write zone map";   msg_eol = "can't write zone map";
259   xwrite(dev_fd, G.zone_map, SB_ZMAPS * BLOCK_SIZE);   xwrite(dev_fd, G.zone_map, SB_ZMAPS * BLOCK_SIZE);
260    
261   msg_eol = "cannot write inodes";   msg_eol = "can't write inodes";
262   xwrite(dev_fd, G.inode_buffer, INODE_BUFFER_SIZE);   xwrite(dev_fd, G.inode_buffer, INODE_BUFFER_SIZE);
263    
264   msg_eol = "\n";   msg_eol = "\n";
# Line 504  static void alarm_intr(int alnum UNUSED_ Line 505  static void alarm_intr(int alnum UNUSED_
505   if (!G.currently_testing)   if (!G.currently_testing)
506   return;   return;
507   printf("%d ...", G.currently_testing);   printf("%d ...", G.currently_testing);
508   fflush(stdout);   fflush_all();
509  }  }
510    
511  static void check_blocks(void)  static void check_blocks(void)
# Line 623  static void setup_tables(void) Line 624  static void setup_tables(void)
624  int mkfs_minix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;  int mkfs_minix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
625  int mkfs_minix_main(int argc UNUSED_PARAM, char **argv)  int mkfs_minix_main(int argc UNUSED_PARAM, char **argv)
626  {  {
  struct mntent *mp;  
627   unsigned opt;   unsigned opt;
628   char *tmp;   char *tmp;
629   struct stat statbuf;   struct stat statbuf;
# Line 682  int mkfs_minix_main(int argc UNUSED_PARA Line 682  int mkfs_minix_main(int argc UNUSED_PARA
682   G.total_blocks = 65535;   G.total_blocks = 65535;
683    
684   /* Check if it is mounted */   /* Check if it is mounted */
685   mp = find_mount_point(G.device_name, NULL);   if (find_mount_point(G.device_name, 0))
686   if (mp && strcmp(G.device_name, mp->mnt_fsname) == 0)   bb_error_msg_and_die("can't format mounted filesystem");
  bb_error_msg_and_die("%s is mounted on %s; "  
  "refusing to make a filesystem",  
  G.device_name, mp->mnt_dir);  
687    
688   xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);   xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);
689   if (fstat(dev_fd, &statbuf) < 0)   if (fstat(dev_fd, &statbuf) < 0)
690   bb_error_msg_and_die("cannot stat %s", G.device_name);   bb_error_msg_and_die("can't stat %s", G.device_name);
691   if (!S_ISBLK(statbuf.st_mode))   if (!S_ISBLK(statbuf.st_mode))
692   opt &= ~1; // clear -c (check)   opt &= ~1; // clear -c (check)
693    

Legend:
Removed from v.983  
changed lines
  Added in v.984