Upload Tizen:Base source
[framework/base/util-linux-ng.git] / fdisk / fdiskmaclabel.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 "fdiskmaclabel.h"
15 #include "nls.h"
16
17 #define MAC_BITMASK 0xffff0000
18
19
20 static  int     other_endian = 0;
21 static  short   volumes=1;
22
23 /*
24  * only dealing with free blocks here
25  */
26
27 static void
28 mac_info( void ) {
29     puts(
30         _("\n\tThere is a valid Mac label on this disk.\n"
31         "\tUnfortunately fdisk(1) cannot handle these disks.\n"
32         "\tUse either pdisk or parted to modify the partition table.\n"
33         "\tNevertheless some advice:\n"
34         "\t1. fdisk will destroy its contents on write.\n"
35         "\t2. Be sure that this disk is NOT a still vital\n"
36         "\t   part of a volume group. (Otherwise you may\n"
37         "\t   erase the other disks as well, if unmirrored.)\n")
38     );
39 }
40
41 void
42 mac_nolabel( void )
43 {
44     maclabel->magic = 0;
45     mac_label = 0;
46     partitions = 4;
47     memset( MBRbuffer, 0, sizeof(MBRbuffer) );  /* avoid fdisk cores */
48     return;
49 }
50
51 int
52 check_mac_label( void )
53 {
54         /*
55         Conversion: only 16 bit should compared
56         e.g.: HFS Label is only 16bit long
57         */
58         int magic_masked = 0 ;
59         magic_masked =  maclabel->magic & MAC_BITMASK ;
60
61         switch (magic_masked) {
62                 case MAC_LABEL_MAGIC :
63                 case MAC_LABEL_MAGIC_2:
64                 case MAC_LABEL_MAGIC_3:
65                         goto IS_MAC;
66                         break;
67                 default:
68                         mac_label = 0;
69                         other_endian = 0;
70                         return 0;
71
72
73         }
74
75 IS_MAC:
76     other_endian = (maclabel->magic == MAC_LABEL_MAGIC_SWAPPED); // =?
77     update_units();
78     mac_label = 1;
79     partitions= 1016; // =?
80     volumes = 15;       // =?
81     mac_info();
82     mac_nolabel();              /* %% */
83     mac_label = 1;              /* %% */
84     return 1;
85 }
86