summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/FDISK/PARTINFO.C
blob: 040ee5a0d03dce815fa7cfcc1d651bedaf8939ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#include "dos.h"                                                        /* AN000 */
#include "fdisk.h"                                                      /* AN000 */
#include "subtype.h"                                                    /* AN000 */
#include "extern.h"                                                     /* AN000 */

/*  */
char find_free_partition()

BEGIN
 char  i;

    /* Look at all four partition entries for empty partition */
    for (i = c(0); i < c(4);i++)                                        /* AC000 */
       BEGIN

        /* if we find an empty one, return which one */
        if (part_table[cur_disk][i].num_sec == ul(0))                   /* AC000 */
           BEGIN
            return(i);
            break;
           END
       END
    /* Did not find one, return NOT_FOUND */
    return(c(NOT_FOUND));                                               /* AC000 */
END

/*  */
char find_partition_type(type)

unsigned char type;

BEGIN
 char  i;

/*  Look at all four partition entries for system id byte that matches */
 for (i = c(0); i < c(4);i++)                                           /* AC000 */
    BEGIN

     /* if we find a match, do a TRUE return */
     if (part_table[cur_disk][i].sys_id == type)
        BEGIN
         return(TRUE);
         break;
        END
    END
 /* Did not find one, return FALSE */
 return(FALSE);
END



/*  */
XFLOAT get_partition_size(type)                                   /* AC000 */

unsigned char type;                                                     /* AC000 */

BEGIN
 char  i;

 /*  Look at all four partition entries for system id byte that matches */
 for (i = c(0); i < c(4);i++)                                           /* AC000 */
    BEGIN

     /* if we find a match, get the size */
     if (part_table[cur_disk][i].sys_id == type)
        BEGIN
         /* Get the size of the partition from the array */
         return(part_table[cur_disk][i].mbytes_used);         /* AC000 */
        END
    END
 /* Did not find one, something bad wrong happened */
 internal_program_error();
END

/*  */
char find_active_partition()

BEGIN

unsigned  char   i;

       /* See if there is an active partition */
       for (i = uc(0); i < uc(4);i++)                                   /* AC000 */
          BEGIN

           /* if we find an active one, TRUE return */
           if (part_table[cur_disk][i].boot_ind == uc(ACTIVE))          /* AC000 */
              BEGIN
               return(TRUE);
               break;
              END
          END
        /* Did not find one, return FALSE */
        return(FALSE);
END


/*  */
char find_partition_location(type)

unsigned char type;

BEGIN
 char  i;

/*  Look at all four partition entries for system id byte that matches */
 for (i = c(0); i < c(4);i++)                                           /* AC000 */
    BEGIN

     /* if we find a match, do a TRUE return */
     if (part_table[cur_disk][i].sys_id == type)
        BEGIN
         return(i);
         break;
        END
    END
 /* Did not find one, return */
 return(c(NOT_FOUND));                                                  /* AC000 */
END

/*  */
char find_free_ext()

BEGIN

 char   i;

    /* Look at all 23 extended entries for empty partition */
    for (i = c(0); i < c(23);i++)                                       /* AC000 */
       BEGIN

        /* if we find an empty one, return which one */
        if (ext_table[cur_disk][i].sys_id == uc(0))                     /* AC000 */
           BEGIN
            return(i);
            break;
           END
       END
    return(c(NOT_FOUND));                                               /* AC000 */
END

/*  */
char find_logical_drive()

BEGIN

unsigned  char  i;

       /* See if there is a logical drive defined in Extended Partition */
       for (i = uc(0); i < uc(23);i++)                                  /* AC000 */
          BEGIN

           /* See if we find a sys id that is not 0 */
           if (ext_table[cur_disk][i].sys_id != uc(0))                  /* AC000 */
              BEGIN
               return(TRUE);
               break;
              END
          END
        return(FALSE);
END

/*  */
char get_num_logical_dos_drives()
BEGIN

char   i;
char number;

       number = c(0);                                                   /* AC000 */
       /* See if there is a logical drive defined in Extended Partition */
       for (i = c(0); i < c(23);i++)                                    /* AC000 */
          BEGIN

           /* See if we find a sys id that is DOS */
           if ((ext_table[cur_disk][i].sys_id == uc(DOS12)) || (ext_table[cur_disk][i].sys_id == uc(DOS16)) ||
              (ext_table[cur_disk][i].sys_id == uc(DOSNEW)))                                                     /* AC000 */
              BEGIN
               number++;
              END
          END
        return(number);
END

/*  */
char find_ext_drive(offset)

char   offset;

BEGIN

char   number_found;
char   i;

        number_found = c(0);                                            /* AC000 */

        /* Go look for the nth extended drive */
        for (i=c(0); i < c(23); i++)                                    /* AC000 */
           BEGIN

            /* See if there is a drive we know about */
            if ((ext_table[cur_disk][i].sys_id == uc(DOS12)) || (ext_table[cur_disk][i].sys_id == uc(DOS16)) ||
               (ext_table[cur_disk][i].sys_id == uc(DOSNEW)))                                   /* AC000 */
               BEGIN
                /* Is this the one we were looking for ? */
                if (number_found == offset)
                   BEGIN
                    /* Yes it is, return where we found it */
                    return(i);
                    break;
                   END
                /* Show we found one and go look for the next */
                number_found++;
               END
           END
        /* We should never get here */
        internal_program_error();
        return(c(INVALID));                                             /* AC000 */
END


/*  */
char find_previous_drive(offset)

char   offset;

BEGIN

char   number_found;
char   last_found;
char   i;

        number_found = c(0);                                            /* AC000 */
        last_found = c(0);                                              /* AC000 */

        /* Go look for the nth extended drive */
        for (i=c(0); i < c(23); i++)                                    /* AC000 */
           BEGIN

            /* See if there is a drive */
            if (ext_table[cur_disk][i].sys_id != uc(0))                 /* AC000 */
               BEGIN
                /* Is this the one we were looking for ? */
                if (number_found == offset)
                   BEGIN
                    /* Yes it is, return where we found the previous one */
                    return(last_found);
                   END
                /* This is the latest one we found, but not the limit, so save it */
                last_found = i;

                /* Show we found one and go look for the next */
                number_found++;
               END
           END
        /* We should never get here */
        internal_program_error();
        return(c(INVALID));                                             /* AC000 */
END