int truncate(const char *path, off_t length) { struct path node; int res; if (0 == (res = fs_perm_lookup(path, NULL, &node))) { errno = -res; res = -1; goto end; } res = ktruncate(node.node, length); end: return res; }
int kftruncate(struct file_desc *desc, off_t length) { int ret; ret = ktruncate(desc->node, length); if (0 > ret) { /* XXX ktruncate sets errno */ return -errno; } if (desc->cursor > length) { desc->cursor = length; } return 0; }