50b06261b6
Implemented by changing write_map to accept a WMAP_FREE flag. In that case, it doesn't update the datablock (creating indirect zones as necessary) pointer, but it frees the datablock if present. Also it frees the single and double indirect blocks if unused. This makes the implementation of truncate_inode() simpler. truncate_inode() now accepts a truncation length which makes implementing truncate() and ftruncate() simple. This also allowed implementing the F_FREESP fcntl().
24 lines
443 B
C
Executable file
24 lines
443 B
C
Executable file
#include <lib.h>
|
|
#include <string.h>
|
|
#define truncate _truncate
|
|
#define ftruncate _ftruncate
|
|
#include <unistd.h>
|
|
|
|
PUBLIC int truncate(const char *_path, off_t _length)
|
|
{
|
|
message m;
|
|
m.m2_p1 = (char *) _path;
|
|
m.m2_i1 = strlen(_path)+1;
|
|
m.m2_l1 = _length;
|
|
|
|
return(_syscall(FS, TRUNCATE, &m));
|
|
}
|
|
|
|
PUBLIC int ftruncate(int _fd, off_t _length)
|
|
{
|
|
message m;
|
|
m.m2_l1 = _length;
|
|
m.m2_i1 = _fd;
|
|
|
|
return(_syscall(FS, FTRUNCATE, &m));
|
|
}
|