-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsuperblockup.c
More file actions
96 lines (92 loc) · 1.71 KB
/
Copy pathsuperblockup.c
File metadata and controls
96 lines (92 loc) · 1.71 KB
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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct superblockmake{
unsigned int inodeuse[16];
unsigned int datause[32];
}superblockmake;
superblockmake superblock = { {0}, {0} };
int super_i_up();
int main(void){
int i , p;
p = 0;
while(p != 1024){
super_d_up();
p++;
}
for(i = 0; i < 32; i++)
printf("%u\n", superblock.datause[i]);
return 0;
}
//super_i_up 파일을 생성시 가용 아이노드슈퍼블록 1로 변경 후 아이노드 넘버 num으로 리턴;
int super_i_up(){
int num, r, i, t, v = 0, k = 1, s;
unsigned int comp;
unsigned int to;
to = 1;
to = to << 31;
while(k){
t = 1;
s = 0;
comp = superblock.inodeuse[v];
while((comp & to) == to){
comp = comp << 1;
s++;
if((s % 32) == 0){
printf("R");
v++;
comp = superblock.inodeuse[v];
}
printf("O");
}
if((comp & to) == 0){
comp = to;
comp = comp >> s;
superblock.inodeuse[v] += comp;
k = 0;
}
if(v == 16)
k = 0;
printf("X");
num = v*32 + (s % 32) + 1;
}
printf("num: %d\n", num);
printf("\n");
return num;
}
//super_d_up 파일을 생성시 가용 데이터블록넘버슈퍼블록 1로 변경후 데이터블록 넘버 num으로 리턴;
int super_d_up(){
int num, r, i, t, v = 0, k = 1, s;
unsigned int comp;
unsigned int to;
to = 1;
to = to << 31;
while(k){
t = 1;
s = 0;
comp = superblock.datause[v];
while((comp & to) == to){
comp = comp << 1;
s++;
if((s % 32) == 0){
printf("R");
v++;
comp = superblock.datause[v];
}
printf("O");
}
if((comp & to) == 0){
comp = to;
comp = comp >> s;
superblock.datause[v] += comp;
k = 0;
}
if(v == 32)
k = 0;
printf("X");
num = v*32 + (s % 32) + 1;
}
printf("num: %d\n", num);
printf("\n");
return num;
}