-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpath.c
684 lines (610 loc) · 21 KB
/
path.c
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "dir.h"
#include "buf.h"
#include "file.h"
#include "inode.h"
#include "super.h"
#include "myfs.h"
/* char dot1[2] = "."; [> used for search_dir to bypass the access <] */
/* char dot2[3] = ".."; [> permissions for . and .. <] */
void write_index1_block(struct buf * index, zone_t z, int pos){
/* struct buf * bp; */
/* bp = get_block(index); */
/* bp->b_ind[pos] = z; */
/* bp->b_dirt = DIRTY; */
if(pos > NR_INDIRECT_BLOCK){
printf("position in the indirect block is bigger than 128");
exit(1);
}
/* put_block(bp); */
index->b_ind[pos] = z;
index->b_dirt = DIRTY;
}
void write_index2_block(struct buf * index, zone_t z, int pos){
struct buf * bp;
int block_pos, boff;
block_pos = pos / NR_INDIRECT_BLOCK;
boff = pos % NR_INDIRECT_BLOCK;
if (index->b_ind[block_pos] == NO_ZONE){
if(boff != 0){
printf("this is not the first time to allocate a new index1 block in the index2 block, block_pos is %d, and boff is %d\n", block_pos, boff);
}
index->b_ind[block_pos] = (block_t)alloc_zone(z);
index->b_dirt = DIRTY;
bp = get_block(index->b_ind[block_pos]);
zero_block(bp);
}else{
if(boff == 0){
printf("not allocate a new index1 block in the index2 block\n");
}
bp = get_block(index->b_ind[block_pos]);
}
write_index1_block(bp, z, boff);
put_block(bp);
}
void write_index3_block(struct buf * index, zone_t z, int pos){
struct buf * bp;
int block_pos, boff;
block_pos = pos / NR_INDIRECT_BLOCK_2;
boff = pos % NR_INDIRECT_BLOCK_2;
if (index->b_ind[block_pos] == NO_ZONE){
if(boff != 0){
printf("this is not the first time to allocate a new index2 block in the index3 block, block_pos is %d, and boff is %d\n", block_pos, boff);
}
index->b_ind[block_pos] = (block_t)alloc_zone(z);
index->b_dirt = DIRTY;
bp = get_block(index->b_ind[block_pos]);
zero_block(bp);
}else{
if(boff == 0){
printf("not allocate a new index2 block in the index3 block\n");
}
bp = get_block(index->b_ind[block_pos]);
}
write_index2_block(bp, z, boff);
put_block(bp);
}
struct buf* new_block(struct inode * rip, int position){
struct buf * bp;
int boff, block_pos, origin_pos;
zone_t z;
block_t b;
block_pos = position / S_BLOCK_SIZE;
if (rip->i_zone[0] == NO_ZONE){
z = S_FIRSTDATAZONE;
}else {
z = rip->i_zone[0];
}
/* printf("the block_pos is %d\n", block_pos); */
z = (block_t)alloc_zone(z);
/* if (z != (S_FIRSTDATAZONE + 1)){ */
/* printf("allocate zone is not as expected, allocate zone number %d\n", z); */
/* } */
/* printf("here\n");exit(0); */
if (block_pos < DIRECT_ZONE){
rip->i_zone[block_pos] = z;
/* printf("allocate a new data block for root inode: %d\n", (int)z); */
rip->i_dirt = DIRTY;
}else if (block_pos < INDEX1_ZONE){
if (rip->i_zone[10] == NO_ZONE){
/*assert only the first index block alloct a new block*/
if(block_pos != DIRECT_ZONE){
printf("this time is not the first time to alloct a new index1 zone!!\n");
return NIL_BUF;
}
rip->i_zone[10] = (block_t)alloc_zone(z);
rip->i_dirt = DIRTY;
bp = get_block(rip->i_zone[10]);
zero_block(bp);
}else{
if(block_pos == DIRECT_ZONE){
printf("this time not alloct a new index1 zone!!\n");
return NIL_BUF;
}
bp = get_block(rip->i_zone[10]);
}
write_index1_block(bp, z, block_pos - DIRECT_ZONE);
put_block(bp);
}else if (block_pos < INDEX2_ZONE_1) {
if (rip->i_zone[11] == NO_ZONE){
/*assert only the first index block alloct a new block*/
if(block_pos != INDEX1_ZONE){
printf("this time is not the first time to alloct a new index2_1 zone!!\n");
return NIL_BUF;
}
rip->i_zone[11] = (block_t)alloc_zone(z);
rip->i_dirt = DIRTY;
bp = get_block(rip->i_zone[11]);
zero_block(bp);
}else{
if(block_pos == INDEX1_ZONE){
printf("this time not alloct a new index1 zone!!\n");
return NIL_BUF;
}
bp = get_block(rip->i_zone[11]);
}
write_index2_block(bp, z, block_pos - INDEX1_ZONE);
put_block(bp);
}else if (block_pos < INDEX2_ZONE_2) {
if (rip->i_zone[12] == NO_ZONE){
/*assert only the first index block alloct a new block*/
if(block_pos != INDEX2_ZONE_1){
printf("this time is not the first time to alloct a new index2_2 zone!!\n");
return NIL_BUF;
}
rip->i_zone[12] = (block_t)alloc_zone(z);
rip->i_dirt = DIRTY;
bp = get_block(rip->i_zone[12]);
zero_block(bp);
}else{
if(block_pos == INDEX2_ZONE_1){
printf("this time not alloct a new index1 zone!!\n");
return NIL_BUF;
}
bp = get_block(rip->i_zone[12]);
}
write_index2_block(bp, z, block_pos - INDEX2_ZONE_1);
put_block(bp);
}else if (block_pos < INDEX3_ZONE) {
if (rip->i_zone[13] == NO_ZONE){
/*assert only the first index block alloct a new block*/
if(block_pos != INDEX2_ZONE_2){
printf("this time is not the first time to alloct a new index2_3 zone!!\n");
return NIL_BUF;
}
rip->i_zone[13] = (block_t)alloc_zone(z);
rip->i_dirt = DIRTY;
bp = get_block(rip->i_zone[13]);
zero_block(bp);
}else{
if(block_pos == INDEX2_ZONE_2){
printf("this time not alloct a new index1 zone!!\n");
return NIL_BUF;
}
bp = get_block(rip->i_zone[13]);
}
write_index3_block(bp, z, block_pos - INDEX2_ZONE_2);
put_block(bp);
}
b = (block_t)z;
bp = get_block(b);
/* exit(0); */
zero_block(bp);
return(bp);
}
block_t read_index1_block(block_t index, int pos){
struct buf * bp;
block_t b;
bp = get_block(index);
if(pos > NR_INDIRECT_BLOCK){
printf("position in the indirect block is bigger than 128");
exit(1);
}
b = (block_t)bp->b_ind[pos];
put_block(bp);
return b;
}
block_t read_index2_block(block_t index, int pos){
int block_pos, boff;
block_t b;
struct buf * bp;
block_pos = pos/NR_INDIRECT_BLOCK;
boff = pos%NR_INDIRECT_BLOCK;
bp = get_block(index);
b = read_index1_block((block_t)bp->b_ind[block_pos],boff);
put_block(bp);
return b;
}
block_t read_index3_block(block_t index, int pos){
int block_pos, boff;
block_t b;
struct buf * bp;
block_pos = pos/NR_INDIRECT_BLOCK_2;
boff = pos%NR_INDIRECT_BLOCK_2;
bp = get_block(index);
b = read_index2_block((block_t)bp->b_ind[block_pos],boff);
put_block(bp);
return b;
}
block_t read_map(struct inode * rip, int position){
block_t b;
int block_pos;
block_pos = position/S_BLOCK_SIZE; /* relative blk # in file */
/* printf("the block_pos is %d\n", block_pos); */
/* if (block_pos == 0) */
/* return NO_BLOCK; */
if (block_pos < DIRECT_ZONE){
b = (block_t)rip->i_zone[block_pos];
}else if (block_pos < INDEX1_ZONE){
b = read_index1_block(rip->i_zone[10], block_pos - DIRECT_ZONE);
}else if (block_pos < INDEX2_ZONE_1) {
b = read_index2_block(rip->i_zone[11], block_pos - INDEX1_ZONE);
}else if (block_pos < INDEX2_ZONE_2) {
b = read_index2_block(rip->i_zone[12], block_pos - INDEX2_ZONE_1);
}else if (block_pos < INDEX3_ZONE) {
b = read_index3_block(rip->i_zone[13], block_pos - INDEX2_ZONE_2);
}else{
printf("the position is bigger than max file size");
return NO_BLOCK;
}
return(b);
}
struct inode * eat_path(char *path)
{
/* Parse the path 'path' and put its inode in the inode table. If not possible,
* return NIL_INODE as function value and an error code in 'err_code'.
*/
struct inode *ldip, *rip;
char string[DIRSIZ]; /* hold 1 path component name here */
/* First open the path down to the final directory. */
if ( (ldip = last_dir(path, string)) == NIL_INODE) {
return(NIL_INODE); /* we couldn't open final directory */
}
/* The path consisting only of "/" is a special case, check for it. */
if (string[0] == '\0') return(ldip);
/* Get final component of the path. */
rip = advance(ldip, string);
put_inode(ldip);
return(rip);
}
struct inode *last_dir(char *path, char string[DIRSIZ])
{
/* Given a path, 'path', located in the fs address space, parse it as
* far as the last directory, fetch the inode for the last directory into
* the inode table, and return a pointer to the inode. In
* addition, return the final component of the path in 'string'.
* If the last directory can't be opened, return NIL_INODE and
* the reason for failure in 'err_code'.
*/
struct inode *rip;
char *new_name;
struct inode *new_ip;
/* Is the path absolute or relative? Initialize 'rip' accordingly. */
rip = get_inode(1);
/* If dir has been removed or path is empty, return ENOENT. */
if (*path == '\0') {
errno = ENOENT;
return(NIL_INODE);
}
dup_inode(rip); /* inode will be returned with put_inode */
/* Scan the path component by component. */
while (TRUE) {
/* Extract one component. */
if ( (new_name = get_name(path, string)) == (char*) 0) {
put_inode(rip); /* bad path in user space */
return(NIL_INODE);
}
if (*new_name == '\0') {
if ( (rip->i_mode & I_DIRECTORY) ) {
return(rip); /* normal exit */
} else {
/* last file of path prefix is not a directory */
put_inode(rip);
errno = ENOTDIR;
return(NIL_INODE);
}
}
/* There is more path. Keep parsing. */
new_ip = advance(rip, string);
put_inode(rip); /* rip either obsolete or irrelevant */
if (new_ip == NIL_INODE) return(NIL_INODE);
/* The call to advance() succeeded. Fetch next component. */
path = new_name;
rip = new_ip;
}
}
/*===========================================================================*
* get_name *
*===========================================================================*/
char *get_name(char *old_name, char string[DIRSIZ])
{
/* Given a pointer to a path name in fs space, 'old_name', copy the next
* component to 'string' and pad with zeros. A pointer to that part of
* the name as yet unparsed is returned. Roughly speaking,
* 'get_name' = 'old_name' - 'string'.
*
* This routine follows the standard convention that /usr/ast, /usr//ast,
* //usr///ast and /usr/ast/ are all equivalent.
*/
int c;
char *np, *rnp;
np = string; /* 'np' points to current position */
rnp = old_name; /* 'rnp' points to unparsed string */
while ( (c = *rnp) == '/') rnp++; /* skip leading slashes */
/* Copy the unparsed path, 'old_name', to the array, 'string'. */
while ( rnp < &old_name[PATH_MAX] && c != '/' && c != '\0') {
if (np < &string[DIRSIZ]) *np++ = c;
c = *++rnp; /* advance to next character */
}
/* To make /usr/ast/ equivalent to /usr/ast, skip trailing slashes. */
while (c == '/' && rnp < &old_name[PATH_MAX]) c = *++rnp;
if (np < &string[DIRSIZ]) *np = '\0'; /* Terminate string */
if (rnp >= &old_name[PATH_MAX]) {
errno = ENAMETOOLONG;
printf("path name reach to the max size!!!\n");
return((char *) 0);
}
return(rnp);
}
/*===========================================================================*
* advance *
*===========================================================================*/
struct inode *advance(struct inode *dirp, char string[DIRSIZ])
{
/* Given a directory and a component of a path, look up the component in
* the directory, find the inode, open it, and return a pointer to its inode
* slot. If it can't be done, return NIL_INODE.
*/
struct inode *rip;
struct inode *rip2;
struct super_block *sp;
int r, inumb;
int numb = 0;
/* If 'string' is empty, yield same inode straight away. */
if (string[0] == '\0') { return(get_inode((int) dirp->i_num)); }
/* Check for NIL_INODE. */
if (dirp == NIL_INODE) { return(NIL_INODE); }
/* If 'string' is not present in the directory, signal error. */
if ( (r = search_dir(dirp, string, &numb, LOOK_UP)) != OK) {
errno = r;
return(NIL_INODE);
}
if (numb == 0) return (NIL_INODE);
return(get_inode((int) numb));
}
/*===========================================================================*
* search_dir *
*===========================================================================*/
int search_dir(struct inode *ldir_ptr, char string[DIRSIZ], int * numb, int flag)
{
/* This function searches the directory whose inode is pointed to by 'ldip':
* if (flag == ENTER) enter 'string' in the directory with inode # '*numb';
* if (flag == DELETE) delete 'string' from the directory;
* if (flag == LOOK_UP) search for 'string' and return inode # in 'numb';
* if (flag == IS_EMPTY) return OK if only . and .. in dir else ENOTEMPTY;
*
* if 'string' is dot1 or dot2, no access permissions are checked.
*/
struct direct *dp = NULL;
struct buf *bp = NULL;
int i, r, e_hit, t, match;
int bits;
int pos;
unsigned new_slots, old_slots;
block_t b;
struct super_block *sp;
int extended = 0;
if ( !(ldir_ptr->i_mode & I_DIRECTORY)) return(ENOTDIR);
r = OK;
/* Step through the directory one block at a time. */
old_slots = (unsigned) (ldir_ptr->i_size/DIR_ENTRY_SIZE);/* how many directory slots in this inode */
new_slots = 0;
e_hit = FALSE;
match = 0; /* set when a string match occurs */
/* printf("inode size is %d\n", ldir_ptr->i_size); */
for (pos = 0; pos < ldir_ptr->i_size; pos += S_BLOCK_SIZE) {
b = read_map(ldir_ptr, pos); /* get block number */
/* Since directories don't have holes, 'b' cannot be NO_BLOCK. */
bp = get_block(b); /* get a dir block */
if (bp == NIL_BUF){
printf("Search Dir: error occurs: can't get a block\n");exit(1);
}
/* Search a directory block. */
for (dp = &bp->b_dir[0];
dp < &bp->b_dir[NR_DIR_BLOCK];
dp++) {
/* read every slot , add new_slot by 1 */
if (++new_slots > old_slots) { /* not found, but room left */
if (flag == ENTER) e_hit = TRUE;
break;
}
/* printf("the string read is %s\n", dp->d_name); */
/* Match occurs if string found. */
if (flag != ENTER && dp->d_ino != 0) {
if (flag == IS_EMPTY) {
/* If this test succeeds, dir is not empty. */
if (strcmp(dp->d_name, "." ) != 0 &&
strcmp(dp->d_name, "..") != 0) match = 1;
} else {
if (strncmp(dp->d_name, string, DIRSIZ) == 0) {
/* printf("here\n"); */
match = 1;
}
}
}
if (match) {
/* LOOK_UP or DELETE found what it wanted. */
r = OK;
if (flag == DELETE) {
*numb = (int)dp->d_ino;
dp->d_ino = 0;
bp->b_dirt = DIRTY;
ldir_ptr->i_dirt = DIRTY;
} else {
*numb = (int) dp->d_ino;
}
put_block(bp);
return(r);
}
/* Check for free slot for the benefit of ENTER. */
if (flag == ENTER && dp->d_ino == 0) {
printf("here reset a new slot\n");
e_hit = TRUE; /* we found a free slot */
break;
}
}
/* The whole block has been searched or ENTER has a free slot. */
if (e_hit) break; /* e_hit set if ENTER can be performed now */
put_block(bp); /* otherwise, continue searching dir */
}
if(flag != ENTER){
return OK;
}
/* printf("it should not reached here!\n"); */
/* This call is for ENTER. If no free slot has been found so far, try to
* extend directory.
*/
if (e_hit == FALSE) { /* directory is full and no room left in last block */
new_slots++; /* increase directory size by 1 entry */
if (new_slots == 0) {
printf("here new slot is 0\n");
return(EFBIG); /* dir size limited by slot count */
}
/* exit(0); */
if ( (bp = new_block(ldir_ptr, ldir_ptr->i_size)) == NIL_BUF)
return(errno);
dp = &bp->b_dir[0];
extended = 1;
}
/* printf("here, the string to search is %s\n", string);exit(0); */
/* 'bp' now points to a directory block with space. 'dp' points to slot. */
/* exit(0); */
/* printf("new slot is %d\n", new_slots); */
memset(dp->d_name, 0, (size_t) DIRSIZ); /* clear entry */
/* exit(0); */
for(i = 0; i < DIRSIZ && string[i]; ++i)
dp->d_name[i] = string[i];
/* strcpy(dp->d_name, string); */
dp->d_ino = (int) *numb;
bp->b_dirt = DIRTY;
put_block(bp);
ldir_ptr->i_dirt = DIRTY;
if (new_slots > old_slots) {
ldir_ptr->i_size = (int) new_slots * DIR_ENTRY_SIZE;
/* Send the change to disk if the directory is extended. */
if (extended) rw_inode(ldir_ptr, WRITING);
}
return(OK);
}
void print_tab(int num){
int i = 0;
for(; i < num; ++ i){
printf("\t");
}
}
void list_dir(struct inode *rip, int level){
struct inode * item;
struct direct *dp = NULL;
struct buf *bp = NULL;
int pos;
unsigned slots, count;
block_t b;
slots = (unsigned) (rip->i_size/DIR_ENTRY_SIZE);/* how many directory slots in this inode */
count = 0;
for(pos = 0; pos < rip->i_size; pos += S_BLOCK_SIZE){
b = read_map(rip, pos);
bp = get_block(b);
if(bp == NIL_BUF){
printf("get a null buf when list dir\n");
return;
}
for(dp = &bp->b_dir[0]; dp < &bp->b_dir[NR_DIR_BLOCK]; ++ dp){
if(++ count > slots){
break;
}
if(dp->d_ino == 0){
printf("meet a empty inode\n");
break;
}
print_tab(level);
printf("filename: %s ",dp->d_name);
item = get_inode(dp->d_ino);
printf("size: %d ", item->i_size);
if(item->i_mode & I_DIRECTORY){
printf("Directory\n");
if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0){
list_dir(item, level + 1);
}
}else{
printf("Normal\n");
}
put_inode(item);
}
put_block(bp);
}
}
int dir_rename(struct inode* rip, char old_name[NAME_MAX], char new_name[NAME_MAX]){
struct direct *dp = NULL;
struct buf *bp = NULL;
int pos;
unsigned slots, count;
block_t b;
slots = (unsigned) (rip->i_size/DIR_ENTRY_SIZE);/* how many directory slots in this inode */
count = 0;
/* printf("inode's size is %d, number of slots is%d\n", rip->i_size, slots); */
for(pos = 0; pos < rip->i_size; pos += S_BLOCK_SIZE){
b = read_map(rip, pos);
bp = get_block(b);
if(bp == NIL_BUF){
printf("get a null buf when list dir\n");
return;
}
for(dp = &bp->b_dir[0]; dp < &bp->b_dir[NR_DIR_BLOCK]; ++ dp){
if(++ count > slots){
break;
}
if(dp->d_ino == 0){
/* printf("meet a empty inode\n"); */
break;
}
if(strcmp(dp->d_name, old_name) == 0){
my_strcpy(dp->d_name, new_name);
bp->b_dirt = DIRTY;
put_block(bp);
return OK;
}
put_block(bp);
}
}
return -1;
}
void delete_dir(struct inode *rip, int level){
struct inode * item;
struct direct *dp = NULL;
struct buf *bp = NULL;
int pos;
int number;
unsigned slots, count;
block_t b;
print_tab(level);
slots = (unsigned) (rip->i_size/DIR_ENTRY_SIZE);/* how many directory slots in this inode */
count = 0;
/* printf("inode's size is %d, number of slots is%d\n", rip->i_size, slots); */
for(pos = 0; pos < rip->i_size; pos += S_BLOCK_SIZE){
b = read_map(rip, pos);
bp = get_block(b);
if(bp == NIL_BUF){
printf("get a null buf when list dir\n");
return;
}
for(dp = &bp->b_dir[0]; dp < &bp->b_dir[NR_DIR_BLOCK]; ++ dp){
if(++ count > slots){
break;
}
if(dp->d_ino == 0){
printf("meet a empty inode\n");
break;
}
if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0){
print_tab(level);
printf("delete filename: %s ",dp->d_name);
item = get_inode(dp->d_ino);
if(item->i_mode & I_DIRECTORY){
printf("Directory\n");
delete_dir(item, level + 1);
}else{
printf("Normal\n");
}
empty_inode_space(item);
number = item->i_num;
put_inode(item);
printf("free_inode %d\n", number);
free_inode(number);
}
}
put_block(bp);
}
}