hush/util-linux/fdisk_aix.c
Denys Vlasenko ddf7850f2b fdisk: add a warning and truncate disks with >= 2^32 sectors
As a result, for sectors we can use uint32_t instead of long long,
and on 32 bits it has drastic effects:

function                                             old     new   delta
get_geometry                                         619     646     +27
set_sun_partition                                    148     150      +2
get_partition                                        134     135      +1
xbsd_write_bootstrap                                 382     381      -1
xbsd_readlabel                                       247     246      -1
bsd_select                                          1674    1672      -2
sun_other_endian                                       4       1      -3
scsi_disk                                              4       1      -3
floppy                                                 4       1      -3
fdisk_main                                          3735    3732      -3
read_maybe_empty                                      43      37      -6
create_doslabel                                      111     104      -7
read_line                                             97      88      -9
add_logical                                          117     107     -10
write_table                                          599     588     -11
new_partition                                       1684    1670     -14
list_disk_geometry                                   229     215     -14
wrong_p_order                                        130     110     -20
xselect                                             3142    3114     -28
seek_sector                                           71      40     -31
get_boot                                            1576    1533     -43
fill_bounds                                          174     128     -46
delete_partition                                     603     551     -52
list_table                                          1401    1232    -169
set_partition                                        459     286    -173
verify                                              1840    1495    -345
add_partition                                       2486    1270   -1216
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/24 up/down: 30/-2210)       Total: -2180 bytes
   text    data     bss     dec     hex filename
 848812     460    7116  856388   d1144 busybox_old
 846620     460    7108  854188   d08ac busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-16 03:03:13 +02:00

75 lines
1.9 KiB
C

#if ENABLE_FEATURE_AIX_LABEL
/*
* Copyright (C) Andreas Neuper, Sep 1998.
*
* Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
typedef struct {
unsigned int magic; /* expect AIX_LABEL_MAGIC */
unsigned int fillbytes1[124];
unsigned int physical_volume_id;
unsigned int fillbytes2[124];
} aix_partition;
#define AIX_LABEL_MAGIC 0xc9c2d4c1
#define AIX_LABEL_MAGIC_SWAPPED 0xc1d4c2c9
#define AIX_INFO_MAGIC 0x00072959
#define AIX_INFO_MAGIC_SWAPPED 0x59290700
#define aixlabel ((aix_partition *)MBRbuffer)
/*
Changes:
* 1999-03-20 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
* Internationalization
*
* 2003-03-20 Phillip Kesling <pkesling@sgi.com>
* Some fixes
*/
static smallint aix_other_endian; /* bool */
static smallint aix_volumes = 1; /* max 15 */
/*
* only dealing with free blocks here
*/
static void
aix_info(void)
{
puts("\n"
"There is a valid AIX label on this disk.\n"
"Unfortunately Linux cannot handle these disks at the moment.\n"
"Nevertheless some advice:\n"
"1. fdisk will destroy its contents on write.\n"
"2. Be sure that this disk is NOT a still vital part of a volume group.\n"
" (Otherwise you may erase the other disks as well, if unmirrored.)\n"
"3. Before deleting this physical volume be sure to remove the disk\n"
" logically from your AIX machine. (Otherwise you become an AIXpert).\n"
);
}
static int
check_aix_label(void)
{
if (aixlabel->magic != AIX_LABEL_MAGIC
&& aixlabel->magic != AIX_LABEL_MAGIC_SWAPPED
) {
current_label_type = 0;
aix_other_endian = 0;
return 0;
}
aix_other_endian = (aixlabel->magic == AIX_LABEL_MAGIC_SWAPPED);
update_units();
current_label_type = LABEL_AIX;
g_partitions = 1016;
aix_volumes = 15;
aix_info();
/*aix_nolabel();*/ /* %% */
/*aix_label = 1;*/ /* %% */
return 1;
}
#endif /* AIX_LABEL */