Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/util-linux/fdisk_sun.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 1  Line 1 
1    /*
2     * fdisk_sun.c
3     *
4     * I think this is mostly, or entirely, due to
5     *      Jakub Jelinek (jj@sunsite.mff.cuni.cz), July 1996
6     *
7     * Merged with fdisk for other architectures, aeb, June 1998.
8     *
9     * Sat Mar 20 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
10     *      Internationalization
11     *
12     * Licensed under GPLv2, see file LICENSE in this tarball for details.
13     */
14    
15  #if ENABLE_FEATURE_SUN_LABEL  #if ENABLE_FEATURE_SUN_LABEL
16    
17  #define SUNOS_SWAP 3  #define SUNOS_SWAP 3
# Line 13  Line 27 
27    
28  #define SCSI_IOCTL_GET_IDLUN 0x5382  #define SCSI_IOCTL_GET_IDLUN 0x5382
29    
30  /*  static smallint sun_other_endian;
31   * fdisksunlabel.c  static smallint scsi_disk;
32   *  static smallint floppy;
  * I think this is mostly, or entirely, due to  
  *      Jakub Jelinek (jj@sunsite.mff.cuni.cz), July 1996  
  *  
  * Merged with fdisk for other architectures, aeb, June 1998.  
  *  
  * Sat Mar 20 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br>  
  *      Internationalization  
  */  
   
   
 static int sun_other_endian;  
 static int scsi_disk;  
 static int floppy;  
33    
34  #ifndef IDE0_MAJOR  #ifndef IDE0_MAJOR
35  #define IDE0_MAJOR 3  #define IDE0_MAJOR 3
# Line 80  static const char *const sun_sys_types[] Line 81  static const char *const sun_sys_types[]
81    
82    
83  static void  static void
84  set_sun_partition(int i, uint start, uint stop, int sysid)  set_sun_partition(int i, unsigned start, unsigned stop, int sysid)
85  {  {
86   sunlabel->infos[i].id = sysid;   sunlabel->infos[i].id = sysid;
87   sunlabel->partitions[i].start_cylinder =   sunlabel->partitions[i].start_cylinder =
# Line 97  check_sun_label(void) Line 98  check_sun_label(void)
98   int csum;   int csum;
99    
100   if (sunlabel->magic != SUN_LABEL_MAGIC   if (sunlabel->magic != SUN_LABEL_MAGIC
101   && sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED) {   && sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED
102     ) {
103   current_label_type = LABEL_DOS;   current_label_type = LABEL_DOS;
104   sun_other_endian = 0;   sun_other_endian = 0;
105   return 0;   return 0;
# Line 172  sun_autoconfigure_scsi(void) Line 174  sun_autoconfigure_scsi(void)
174   return NULL;   return NULL;
175    
176   sprintf(buffer,   sprintf(buffer,
177   "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n",   "Host: scsi%u Channel: %02u Id: %02u Lun: %02u\n",
178   /* This is very wrong (works only if you have one HBA),   /* This is very wrong (works only if you have one HBA),
179     but I haven't found a way how to get hostno     but I haven't found a way how to get hostno
180     from the current kernel */     from the current kernel */
# Line 316  create_sunlabel(void) Line 318  create_sunlabel(void)
318   }   }
319    
320   snprintf((char *)(sunlabel->info), sizeof(sunlabel->info),   snprintf((char *)(sunlabel->info), sizeof(sunlabel->info),
321   "%s%s%s cyl %d alt %d hd %d sec %d",   "%s%s%s cyl %u alt %u hd %u sec %u",
322   p ? p->vendor : "", (p && *p->vendor) ? " " : "",   p ? p->vendor : "", (p && *p->vendor) ? " " : "",
323   p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"),   p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"),
324   g_cylinders, SUN_SSWAP16(sunlabel->nacyl), g_heads, g_sectors);   g_cylinders, SUN_SSWAP16(sunlabel->nacyl), g_heads, g_sectors);
# Line 360  toggle_sunflags(int i, unsigned char mas Line 362  toggle_sunflags(int i, unsigned char mas
362  }  }
363    
364  static void  static void
365  fetch_sun(uint *starts, uint *lens, uint *start, uint *stop)  fetch_sun(unsigned *starts, unsigned *lens, unsigned *start, unsigned *stop)
366  {  {
367   int i, continuous = 1;   int i, continuous = 1;
368    
# Line 389  fetch_sun(uint *starts, uint *lens, uint Line 391  fetch_sun(uint *starts, uint *lens, uint
391   }   }
392  }  }
393    
394  static uint *verify_sun_starts;  static unsigned *verify_sun_starts;
395    
396  static int  static int
397  verify_sun_cmp(int *a, int *b)  verify_sun_cmp(int *a, int *b)
# Line 403  verify_sun_cmp(int *a, int *b) Line 405  verify_sun_cmp(int *a, int *b)
405  static void  static void
406  verify_sun(void)  verify_sun(void)
407  {  {
408   uint starts[8], lens[8], start, stop;   unsigned starts[8], lens[8], start, stop;
409   int i,j,k,starto,endo;   int i,j,k,starto,endo;
410   int array[8];   int array[8];
411    
# Line 412  verify_sun(void) Line 414  verify_sun(void)
414   for (k = 0; k < 7; k++) {   for (k = 0; k < 7; k++) {
415   for (i = 0; i < 8; i++) {   for (i = 0; i < 8; i++) {
416   if (k && (lens[i] % (g_heads * g_sectors))) {   if (k && (lens[i] % (g_heads * g_sectors))) {
417   printf("Partition %d doesn't end on cylinder boundary\n", i+1);   printf("Partition %u doesn't end on cylinder boundary\n", i+1);
418   }   }
419   if (lens[i]) {   if (lens[i]) {
420   for (j = 0; j < i; j++)   for (j = 0; j < i; j++)
# Line 432  verify_sun(void) Line 434  verify_sun(void)
434   endo = starts[i]+lens[i];   endo = starts[i]+lens[i];
435   if (starts[j]+lens[j] < endo)   if (starts[j]+lens[j] < endo)
436   endo = starts[j]+lens[j];   endo = starts[j]+lens[j];
437   printf("Partition %d overlaps with others in "   printf("Partition %u overlaps with others in "
438   "sectors %d-%d\n", i+1, starto, endo);   "sectors %u-%u\n", i+1, starto, endo);
439   }   }
440   }   }
441   }   }
# Line 454  verify_sun(void) Line 456  verify_sun(void)
456   }   }
457   stop = g_cylinders * g_heads * g_sectors;   stop = g_cylinders * g_heads * g_sectors;
458   if (starts[array[0]])   if (starts[array[0]])
459   printf("Unused gap - sectors 0-%d\n", starts[array[0]]);   printf("Unused gap - sectors %u-%u\n", 0, starts[array[0]]);
460   for (i = 0; i < 7 && array[i+1] != -1; i++) {   for (i = 0; i < 7 && array[i+1] != -1; i++) {
461   printf("Unused gap - sectors %d-%d\n", starts[array[i]]+lens[array[i]], starts[array[i+1]]);   printf("Unused gap - sectors %u-%u\n", starts[array[i]]+lens[array[i]], starts[array[i+1]]);
462   }   }
463   start = starts[array[i]] + lens[array[i]];   start = starts[array[i]] + lens[array[i]];
464   if (start < stop)   if (start < stop)
465   printf("Unused gap - sectors %d-%d\n", start, stop);   printf("Unused gap - sectors %u-%u\n", start, stop);
466  }  }
467    
468  static void  static void
469  add_sun_partition(int n, int sys)  add_sun_partition(int n, int sys)
470  {  {
471   uint start, stop, stop2;   unsigned start, stop, stop2;
472   uint starts[8], lens[8];   unsigned starts[8], lens[8];
473   int whole_disk = 0;   int whole_disk = 0;
474    
475   char mesg[256];   char mesg[256];
# Line 528  and is of type 'Whole disk'\n"); Line 530  and is of type 'Whole disk'\n");
530   whole_disk = 1;   whole_disk = 1;
531   break;   break;
532   }   }
533   printf("Sector %d is already allocated\n", first);   printf("Sector %u is already allocated\n", first);
534   } else   } else
535   break;   break;
536   }   }
# Line 559  and is of type 'Whole disk'\n"); Line 561  and is of type 'Whole disk'\n");
561   } else if (last > stop) {   } else if (last > stop) {
562   printf(   printf(
563  "You haven't covered the whole disk with the 3rd partition,\n"  "You haven't covered the whole disk with the 3rd partition,\n"
564  "but your value %d %s covers some other partition.\n"  "but your value %u %s covers some other partition.\n"
565  "Your entry has been changed to %d %s\n",  "Your entry has been changed to %u %s\n",
566   scround(last), str_units(SINGULAR),   scround(last), str_units(SINGULAR),
567   scround(stop), str_units(SINGULAR));   scround(stop), str_units(SINGULAR));
568   last = stop;   last = stop;
# Line 626  sun_list_table(int xtra) Line 628  sun_list_table(int xtra)
628   w = strlen(disk_device);   w = strlen(disk_device);
629   if (xtra)   if (xtra)
630   printf(   printf(
631   "\nDisk %s (Sun disk label): %d heads, %d sectors, %d rpm\n"   "\nDisk %s (Sun disk label): %u heads, %u sectors, %u rpm\n"
632   "%d cylinders, %d alternate cylinders, %d physical cylinders\n"   "%u cylinders, %u alternate cylinders, %u physical cylinders\n"
633   "%d extra sects/cyl, interleave %d:1\n"   "%u extra sects/cyl, interleave %u:1\n"
634   "%s\n"   "%s\n"
635   "Units = %s of %d * 512 bytes\n\n",   "Units = %s of %u * 512 bytes\n\n",
636   disk_device, g_heads, g_sectors, SUN_SSWAP16(sunlabel->rspeed),   disk_device, g_heads, g_sectors, SUN_SSWAP16(sunlabel->rspeed),
637   g_cylinders, SUN_SSWAP16(sunlabel->nacyl),   g_cylinders, SUN_SSWAP16(sunlabel->nacyl),
638   SUN_SSWAP16(sunlabel->pcylcount),   SUN_SSWAP16(sunlabel->pcylcount),
# Line 640  sun_list_table(int xtra) Line 642  sun_list_table(int xtra)
642   str_units(PLURAL), units_per_sector);   str_units(PLURAL), units_per_sector);
643   else   else
644   printf(   printf(
645   "\nDisk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n"   "\nDisk %s (Sun disk label): %u heads, %u sectors, %u cylinders\n"
646   "Units = %s of %d * 512 bytes\n\n",   "Units = %s of %u * 512 bytes\n\n",
647   disk_device, g_heads, g_sectors, g_cylinders,   disk_device, g_heads, g_sectors, g_cylinders,
648   str_units(PLURAL), units_per_sector);   str_units(PLURAL), units_per_sector);
649    
# Line 651  sun_list_table(int xtra) Line 653  sun_list_table(int xtra)
653   if (sunlabel->partitions[i].num_sectors) {   if (sunlabel->partitions[i].num_sectors) {
654   uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * g_heads * g_sectors;   uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * g_heads * g_sectors;
655   uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors);   uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors);
656   printf("%s %c%c %9ld %9ld %9ld%c  %2x  %s\n",   printf("%s %c%c %9lu %9lu %9lu%c  %2x  %s\n",
657   partname(disk_device, i+1, w), /* device */   partname(disk_device, i+1, w), /* device */
658   (sunlabel->infos[i].flags & 0x01) ? 'u' : ' ',  /* flags */   (sunlabel->infos[i].flags & 0x01) ? 'u' : ' ',  /* flags */
659   (sunlabel->infos[i].flags & 0x10) ? 'r' : ' ',   (sunlabel->infos[i].flags & 0x10) ? 'r' : ' ',

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