|
11 | 11 | #include <linux/statfs.h> |
12 | 12 | #include <linux/ethtool.h> |
13 | 13 | #include <linux/falloc.h> |
| 14 | +#include <linux/mount.h> |
14 | 15 |
|
15 | 16 | #include "glob.h" |
16 | 17 | #include "smbfsctl.h" |
@@ -2918,7 +2919,6 @@ int smb2_open(struct ksmbd_work *work) |
2918 | 2919 | goto err_out; |
2919 | 2920 | } |
2920 | 2921 |
|
2921 | | - fp->filename = name; |
2922 | 2922 | fp->cdoption = req->CreateDisposition; |
2923 | 2923 | fp->daccess = daccess; |
2924 | 2924 | fp->saccess = req->ShareAccess; |
@@ -3270,14 +3270,13 @@ int smb2_open(struct ksmbd_work *work) |
3270 | 3270 | if (!rsp->hdr.Status) |
3271 | 3271 | rsp->hdr.Status = STATUS_UNEXPECTED_IO_ERROR; |
3272 | 3272 |
|
3273 | | - if (!fp || !fp->filename) |
3274 | | - kfree(name); |
3275 | 3273 | if (fp) |
3276 | 3274 | ksmbd_fd_put(work, fp); |
3277 | 3275 | smb2_set_err_rsp(work); |
3278 | 3276 | ksmbd_debug(SMB, "Error response: %x\n", rsp->hdr.Status); |
3279 | 3277 | } |
3280 | 3278 |
|
| 3279 | + kfree(name); |
3281 | 3280 | kfree(lc); |
3282 | 3281 |
|
3283 | 3282 | return 0; |
@@ -3895,8 +3894,6 @@ int smb2_query_dir(struct ksmbd_work *work) |
3895 | 3894 | ksmbd_debug(SMB, "Search pattern is %s\n", srch_ptr); |
3896 | 3895 | } |
3897 | 3896 |
|
3898 | | - ksmbd_debug(SMB, "Directory name is %s\n", dir_fp->filename); |
3899 | | - |
3900 | 3897 | if (srch_flag & SMB2_REOPEN || srch_flag & SMB2_RESTART_SCANS) { |
3901 | 3898 | ksmbd_debug(SMB, "Restart directory scan\n"); |
3902 | 3899 | generic_file_llseek(dir_fp->filp, 0, SEEK_SET); |
@@ -4390,9 +4387,9 @@ static int get_file_all_info(struct ksmbd_work *work, |
4390 | 4387 | return -EACCES; |
4391 | 4388 | } |
4392 | 4389 |
|
4393 | | - filename = convert_to_nt_pathname(fp->filename); |
4394 | | - if (!filename) |
4395 | | - return -ENOMEM; |
| 4390 | + filename = convert_to_nt_pathname(work->tcon->share_conf, &fp->filp->f_path); |
| 4391 | + if (IS_ERR(filename)) |
| 4392 | + return PTR_ERR(filename); |
4396 | 4393 |
|
4397 | 4394 | inode = file_inode(fp->filp); |
4398 | 4395 | generic_fillattr(file_mnt_user_ns(fp->filp), inode, &stat); |
@@ -4999,15 +4996,17 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, |
4999 | 4996 | case FS_SECTOR_SIZE_INFORMATION: |
5000 | 4997 | { |
5001 | 4998 | struct smb3_fs_ss_info *info; |
| 4999 | + unsigned int sector_size = |
| 5000 | + min_t(unsigned int, path.mnt->mnt_sb->s_blocksize, 4096); |
5002 | 5001 |
|
5003 | 5002 | info = (struct smb3_fs_ss_info *)(rsp->Buffer); |
5004 | 5003 |
|
5005 | | - info->LogicalBytesPerSector = cpu_to_le32(stfs.f_bsize); |
| 5004 | + info->LogicalBytesPerSector = cpu_to_le32(sector_size); |
5006 | 5005 | info->PhysicalBytesPerSectorForAtomicity = |
5007 | | - cpu_to_le32(stfs.f_bsize); |
5008 | | - info->PhysicalBytesPerSectorForPerf = cpu_to_le32(stfs.f_bsize); |
| 5006 | + cpu_to_le32(sector_size); |
| 5007 | + info->PhysicalBytesPerSectorForPerf = cpu_to_le32(sector_size); |
5009 | 5008 | info->FSEffPhysicalBytesPerSectorForAtomicity = |
5010 | | - cpu_to_le32(stfs.f_bsize); |
| 5009 | + cpu_to_le32(sector_size); |
5011 | 5010 | info->Flags = cpu_to_le32(SSINFO_FLAGS_ALIGNED_DEVICE | |
5012 | 5011 | SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE); |
5013 | 5012 | info->ByteOffsetForSectorAlignment = 0; |
@@ -5683,8 +5682,7 @@ static int set_file_allocation_info(struct ksmbd_work *work, |
5683 | 5682 | size = i_size_read(inode); |
5684 | 5683 | rc = ksmbd_vfs_truncate(work, fp, alloc_blks * 512); |
5685 | 5684 | if (rc) { |
5686 | | - pr_err("truncate failed! filename : %s, err %d\n", |
5687 | | - fp->filename, rc); |
| 5685 | + pr_err("truncate failed!, err %d\n", rc); |
5688 | 5686 | return rc; |
5689 | 5687 | } |
5690 | 5688 | if (size < alloc_blks * 512) |
@@ -5714,12 +5712,10 @@ static int set_end_of_file_info(struct ksmbd_work *work, struct ksmbd_file *fp, |
5714 | 5712 | * truncated range. |
5715 | 5713 | */ |
5716 | 5714 | if (inode->i_sb->s_magic != MSDOS_SUPER_MAGIC) { |
5717 | | - ksmbd_debug(SMB, "filename : %s truncated to newsize %lld\n", |
5718 | | - fp->filename, newsize); |
| 5715 | + ksmbd_debug(SMB, "truncated to newsize %lld\n", newsize); |
5719 | 5716 | rc = ksmbd_vfs_truncate(work, fp, newsize); |
5720 | 5717 | if (rc) { |
5721 | | - ksmbd_debug(SMB, "truncate failed! filename : %s err %d\n", |
5722 | | - fp->filename, rc); |
| 5718 | + ksmbd_debug(SMB, "truncate failed!, err %d\n", rc); |
5723 | 5719 | if (rc != -EAGAIN) |
5724 | 5720 | rc = -EBADF; |
5725 | 5721 | return rc; |
@@ -5765,8 +5761,10 @@ static int set_rename_info(struct ksmbd_work *work, struct ksmbd_file *fp, |
5765 | 5761 | if (parent_fp) { |
5766 | 5762 | if (parent_fp->daccess & FILE_DELETE_LE) { |
5767 | 5763 | pr_err("parent dir is opened with delete access\n"); |
| 5764 | + ksmbd_fd_put(work, parent_fp); |
5768 | 5765 | return -ESHARE; |
5769 | 5766 | } |
| 5767 | + ksmbd_fd_put(work, parent_fp); |
5770 | 5768 | } |
5771 | 5769 | next: |
5772 | 5770 | return smb2_rename(work, fp, user_ns, rename_info, |
|
0 commit comments