return ENOTSUP or EINVAL in cases like that. */
ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE,
pst->st_ex_size, space_to_write);
- if (ret == ENOSPC) {
- errno = ENOSPC;
+ if (ret == -1 && errno == ENOSPC) {
return -1;
}
if (ret == 0) {
return 0;
}
DEBUG(10,("[CEPH] strict_allocate_ftruncate: SMB_VFS_FALLOCATE failed with "
- "error %d. Falling back to slow manual allocation\n", ret));
+ "error %d. Falling back to slow manual allocation\n", errno));
/* available disk space is enough or not? */
space_avail = get_dfree_info(fsp->conn,
}
/* Write out the real space on disk. */
- ret = vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write);
- if (ret != 0) {
- errno = ret;
- ret = -1;
- }
-
- return 0;
+ return vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write);
}
static int cephwrap_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len)
}
if (!fruit_fsp_recheck(ad, fsp)) {
- return errno;
+ return -1;
}
/* Let the pwrite code path handle it. */
- return ENOSYS;
+ errno = ENOSYS;
+ return -1;
}
static int fruit_ftruncate(struct vfs_handle_struct *handle,
off_t len)
{
int result;
+ int saved_errno = 0;
struct timespec ts1,ts2;
double timediff;
clock_gettime_mono(&ts1);
result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
+ if (result == -1) {
+ saved_errno = errno;
+ }
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
if (timediff > audit_timeout) {
smb_time_audit_log_fsp("fallocate", timediff, fsp);
}
-
+ if (result == -1) {
+ errno = saved_errno;
+ }
return result;
}