1 |
/* File truncation |
/* File truncation |
2 |
|
|
3 |
Copyright (C) 1995,96,97,99,2000 Free Software Foundation, Inc. |
Copyright (C) 1995,96,97,99,2000,05 Free Software Foundation, Inc. |
4 |
|
|
5 |
Written by Miles Bader <miles@gnu.org> |
Written by Miles Bader <miles@gnu.org> |
6 |
|
|
124 |
{ |
{ |
125 |
unsigned index; |
unsigned index; |
126 |
int modified = 0, all_freed = 1; |
int modified = 0, all_freed = 1; |
127 |
block_t *ind_bh = (block_t *)bptr (*p); |
block_t *ind_bh = (block_t *)buffer_lookup (*p); |
128 |
unsigned first = end < offset ? 0 : end - offset; |
unsigned first = end < offset ? 0 : end - offset; |
129 |
|
|
130 |
for (index = first; index < addr_per_block; index++) |
for (index = first; index < addr_per_block; index++) |
139 |
|
|
140 |
if (first == 0 && all_freed) |
if (first == 0 && all_freed) |
141 |
{ |
{ |
142 |
pager_flush_some (diskfs_disk_pager, boffs (*p), block_size, 1); |
pager_flush_some (diskfs_disk_pager, |
143 |
|
bptr_index (ind_bh) << log2_block_size, |
144 |
|
block_size, 1); |
145 |
free_block_run_free_ptr (fbr, p); |
free_block_run_free_ptr (fbr, p); |
146 |
|
buffer_put (ind_bh); |
147 |
} |
} |
148 |
else if (modified) |
else if (modified) |
149 |
record_indir_poke (node, ind_bh); |
record_indir_poke (node, ind_bh); |
150 |
|
else |
151 |
|
buffer_put (ind_bh); |
152 |
} |
} |
153 |
} |
} |
154 |
|
|
223 |
/* Flush all the data past the new size from the kernel. Also force any |
/* Flush all the data past the new size from the kernel. Also force any |
224 |
delayed copies of this data to take place immediately. (We are implicitly |
delayed copies of this data to take place immediately. (We are implicitly |
225 |
changing the data to zeros and doing it without the kernel's immediate |
changing the data to zeros and doing it without the kernel's immediate |
226 |
knowledge; accordingl we must help out the kernel thusly.) */ |
knowledge; accordingly we must help out the kernel thusly.) */ |
227 |
static void |
static void |
228 |
force_delayed_copies (struct node *node, off_t length) |
force_delayed_copies (struct node *node, off_t length) |
229 |
{ |
{ |