When providing a length in the stat structure the 9pfs server on the
host will truncate the file to the specified size. We use this to also
enable truncation for the 2000U protocol version. Since uk_9pfs_setattr
checks for the protocol to use, the check can be completely dropped in
uk_9pfs_truncate.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <teodor.teugea@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #834
static int uk_9pfs_truncate(struct vnode *vp, off_t off)
{
- struct uk_9pfs_mount_data *md = UK_9PFS_MD(vp->v_mount);
-
- if (md->proto == UK_9P_PROTO_2000L) {
- struct vattr attr = {
- .va_mask = AT_SIZE,
- .va_size = off,
- };
- return uk_9pfs_setattr(vp, &attr);
- } else {
- return 0;
- }
+ return uk_9pfs_setattr(vp, &(struct vattr){
+ .va_mask = AT_SIZE,
+ .va_size = off,
+ });
}
static int uk_9pfs_rename(struct vnode *dvp1, struct vnode *vp1, char *name1,