Commit df60db4e authored by Linus Torvalds's avatar Linus Torvalds

Make smbfs with UNIX extensions get file disk usage count right.

We need to convert from bytes to blocks, and we also need to
handle the fact that old smbd's will round up the disk usage
bytecount to even multiples of 1MB, and gracefully fall back 
on an estimate based on the file size instead in that case.

Acked by Samuel Thibault who noted the problem in the first
place, and Jeremy Allison wrt smbd behavior.
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 038f9a8f
......@@ -2076,6 +2076,8 @@ smb_proc_readdir_short(struct file *filp, void *dirent, filldir_t filldir,
void smb_decode_unix_basic(struct smb_fattr *fattr, char *p)
{
u64 size, disk_bytes;
/* FIXME: verify nls support. all is sent as utf8? */
fattr->f_unix = 1;
......@@ -2093,8 +2095,19 @@ void smb_decode_unix_basic(struct smb_fattr *fattr, char *p)
/* 84 L permissions */
/* 92 L link count */
fattr->f_size = LVAL(p, 0);
fattr->f_blocks = LVAL(p, 8);
size = LVAL(p, 0);
disk_bytes = LVAL(p, 8);
/*
* Some samba versions round up on-disk byte usage
* to 1MB boundaries, making it useless. When seeing
* that, use the size instead.
*/
if (!(disk_bytes & 0xfffff))
disk_bytes = size+511;
fattr->f_size = size;
fattr->f_blocks = disk_bytes >> 9;
fattr->f_ctime = smb_ntutc2unixutc(LVAL(p, 16));
fattr->f_atime = smb_ntutc2unixutc(LVAL(p, 24));
fattr->f_mtime = smb_ntutc2unixutc(LVAL(p, 32));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment