Upload Tizen:Base source
[framework/base/util-linux-ng.git] / fdisk / fdiskaixlabel.c
1 /*
2   Changes:
3   Sat Mar 20 09:51:38 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
4         Internationalization
5 */
6 #include <stdio.h>              /* stderr */
7 #include <string.h>             /* strstr */
8 #include <unistd.h>             /* write */
9
10 #include <endian.h>
11
12 #include "common.h"
13 #include "fdisk.h"
14 #include "fdiskaixlabel.h"
15 #include "nls.h"
16
17 static  int     other_endian = 0;
18 static  short   volumes=1;
19
20 /*
21  * only dealing with free blocks here
22  */
23
24 static void
25 aix_info( void ) {
26     puts(
27         _("\n\tThere is a valid AIX label on this disk.\n"
28         "\tUnfortunately Linux cannot handle these\n"
29         "\tdisks at the moment.  Nevertheless some\n"
30         "\tadvice:\n"
31         "\t1. fdisk will destroy its contents on write.\n"
32         "\t2. Be sure that this disk is NOT a still vital\n"
33         "\t   part of a volume group. (Otherwise you may\n"
34         "\t   erase the other disks as well, if unmirrored.)\n"
35         "\t3. Before deleting this physical volume be sure\n"
36         "\t   to remove the disk logically from your AIX\n"
37         "\t   machine.  (Otherwise you become an AIXpert).")
38     );
39 }
40
41 void
42 aix_nolabel( void )
43 {
44     aixlabel->magic = 0;
45     aix_label = 0;
46     partitions = 4;
47     memset( MBRbuffer, 0, sizeof(MBRbuffer) );  /* avoid fdisk cores */
48     return;
49 }
50
51 int
52 check_aix_label( void )
53 {
54     if (aixlabel->magic != AIX_LABEL_MAGIC &&
55         aixlabel->magic != AIX_LABEL_MAGIC_SWAPPED) {
56         aix_label = 0;
57         other_endian = 0;
58         return 0;
59     }
60     other_endian = (aixlabel->magic == AIX_LABEL_MAGIC_SWAPPED);
61     update_units();
62     aix_label = 1;
63     partitions= 1016;
64     volumes = 15;
65     aix_info();
66     aix_nolabel();              /* %% */
67     aix_label = 1;              /* %% */
68     return 1;
69 }