From patchwork Fri Jun 22 09:18:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10481549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 52C2160388 for ; Fri, 22 Jun 2018 09:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F4AC2856B for ; Fri, 22 Jun 2018 09:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3379B2862D; Fri, 22 Jun 2018 09:18:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15F162856B for ; Fri, 22 Jun 2018 09:18:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751230AbeFVJSc (ORCPT ); Fri, 22 Jun 2018 05:18:32 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:38525 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751210AbeFVJSb (ORCPT ); Fri, 22 Jun 2018 05:18:31 -0400 Received: by mail-pf0-f176.google.com with SMTP id b74-v6so2931908pfl.5 for ; Fri, 22 Jun 2018 02:18:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Qo99hmrNwwbhquCyD8JPIYTSWoHAgSoBEITzxXbh3OQ=; b=WgRUJbR12c6I0c4M5UzZibHTiv4K5iQT48mfmmEW/cYjTmYdAToMPZeBNK/lrzmlXz N6iNY3h58H72bFWG5TSadYpJeyPFCzdSlyPZeleg/CB/UtqrTndkA13R3cweO4I0b8ig OYQzq5g8iNyR+MVGSJBDE8p7v/scRoOOnea6CxMC0U+A8LFiNpFfqEWoRAk/iXn+wBmi VVqEcVIzQUL7EC+rufQRterAXRj6Vuewhtyel/HeWJa1QyU8OvOTyzegNYrvH63jbwHf ZFW2z1HMkYYzpCSV4JINB7mBF3SEb5hLY3vnY2UJrY+/qtUINTxUHS46qS7y2yExEoBb 2SKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Qo99hmrNwwbhquCyD8JPIYTSWoHAgSoBEITzxXbh3OQ=; b=Lra1W2/b/4JgqmWp81ih50Xvi1sRna69IHeHNwUGgyAmvbOp3FlKuRDjfUrqQ/IT5g Nr0PW8wZ/XdvGKxNokHm1Osek9DcnDVa7wqdBy9/y3WuL17Dh5SrHxM2HgXLHs5NDt36 PmEM9olGxwKuAL33dGTe0iKtTx0VMfFF0iIO3vcgsh9K6yYhUmdiPG0H0BHGQBfmOFVA IZ8h3lwx0V4wglCWO1QRse3N4tHxh3p6MAV7fCPRwQlehFuP8U3PwpMLmTBQiaOvyZ+n ZVIcjUZp4c2/dAG1EdtF7SBNYrorXS5kYb2TVZltlVMmri2mV7RlSOl7bGgmGzL3s9dE vQGw== X-Gm-Message-State: APt69E2xywcTWpDtTqvkIto6EKZgaBhY2m3sapsJ3E+DHtIIpzcow1fn 29EMHPjzco2t+i0taIMSgzuwbGffIXUiT9hKHuLCajCk X-Google-Smtp-Source: ADUXVKJBcETdYnJ44+wYe4SYmahSwD/iuB/7ouPS4hW0z1mrvw0vdfvT3vfCHzS66XQNLM36VnCt40gyq9I7eLJGQsw= X-Received: by 2002:a62:5004:: with SMTP id e4-v6mr851214pfb.71.1529659109912; Fri, 22 Jun 2018 02:18:29 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:80cc:0:0:0:0 with HTTP; Fri, 22 Jun 2018 02:18:09 -0700 (PDT) From: Steve French Date: Fri, 22 Jun 2018 04:18:09 -0500 Message-ID: Subject: [patch][smb3] Fix two fields in statfs output To: CIFS , samba-technical Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix "ID" and "Namelen" fields (which were incorrectly set to 0 and 4096 before). Fixed output is below: foot@smf-Thinkpad-P51:~/cifs-2.6/fs# stat -f /mnt1 File: "/mnt1" ID: d50e5aa000000000 Namelen: 255 Type: smb2 Block size: 1024 Fundamental block size: 1024 Blocks: Total: 234804176 Free: 28232584 Available: 28232584 See attached patch. Would be nice if Samba filled in Volume ID field (and also corrected the block size which in this case should be 4K) From 7a1cdab8d5fd1f243cde3c680636402e3a0964ca Mon Sep 17 00:00:00 2001 From: Steve French Date: Fri, 22 Jun 2018 04:05:30 -0500 Subject: [PATCH 1/2] smb3: fill in statfs fsid and correct namelen Fil in the correct namelen (typically 255 not 4096) in the statfs response and also fill in a reasonably unique fsid (in this case taken from the volume id, and the creation time of the volume). In the case of the POSIX statfs all fields are now filled in, and in the case of non-POSIX mounts, all fields are filled in which can be. Signed-off-by: Steve French CC: Stable --- fs/cifs/cifsfs.c | 17 +++++++++-------- fs/cifs/smb2ops.c | 2 ++ fs/cifs/smb2pdu.c | 8 ++++++++ fs/cifs/smb2pdu.h | 11 +++++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index d5aa7ae917bf..36884a48b656 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -209,14 +209,15 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) xid = get_xid(); - /* - * PATH_MAX may be too long - it would presumably be total path, - * but note that some servers (includinng Samba 3) have a shorter - * maximum path. - * - * Instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO. - */ - buf->f_namelen = PATH_MAX; + if (le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength) > 0) + buf->f_namelen = + le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength); + else + buf->f_namelen = PATH_MAX; + + buf->f_fsid.val[0] = tcon->vol_serial_number; + buf->f_fsid.val[1] = tcon->vol_create_time; /* random, see man statfs */ + buf->f_files = 0; /* undefined */ buf->f_ffree = 0; /* unlimited */ diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 8ac40cf4c115..ee2b75016e78 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -548,6 +548,8 @@ smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon) FS_ATTRIBUTE_INFORMATION); SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, FS_DEVICE_INFORMATION); + SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, + FS_VOLUME_INFORMATION); SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, FS_SECTOR_SIZE_INFORMATION); /* SMB3 specific */ if (no_cached_open) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 96d01444b07d..741df8589051 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -4102,6 +4102,9 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, } else if (level == FS_SECTOR_SIZE_INFORMATION) { max_len = sizeof(struct smb3_fs_ss_info); min_len = sizeof(struct smb3_fs_ss_info); + } else if (level == FS_VOLUME_INFORMATION) { + max_len = sizeof(struct smb3_fs_vol_info) + MAX_VOL_LABEL_LEN; + min_len = sizeof(struct smb3_fs_vol_info); } else { cifs_dbg(FYI, "Invalid qfsinfo level %d\n", level); return -EINVAL; @@ -4146,6 +4149,11 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, tcon->ss_flags = le32_to_cpu(ss_info->Flags); tcon->perf_sector_size = le32_to_cpu(ss_info->PhysicalBytesPerSectorForPerf); + } else if (level == FS_VOLUME_INFORMATION) { + struct smb3_fs_vol_info *vol_info = (struct smb3_fs_vol_info *) + (offset + (char *)rsp); + tcon->vol_serial_number = vol_info->VolumeSerialNumber; + tcon->vol_create_time = vol_info->VolumeCreationTime; } qfsattr_exit: diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 27bea837e43f..a25521795805 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -1251,6 +1251,17 @@ struct smb3_fs_ss_info { __le32 ByteOffsetForPartitionAlignment; } __packed; +/* volume info struct - see MS-FSCC 2.5.9 */ +#define MAX_VOL_LABEL_LEN 32 +struct smb3_fs_vol_info { + __le64 VolumeCreationTime; + __u32 VolumeSerialNumber; + __le32 VolumeLabelLength; /* includes trailing null */ + __u8 SupportsObjects; /* True if eg like NTFS, supports objects */ + __u8 Reserved; + __u8 VolumeLabel[0]; /* variable len */ +} __packed; + /* partial list of QUERY INFO levels */ #define FILE_DIRECTORY_INFORMATION 1 #define FILE_FULL_DIRECTORY_INFORMATION 2 -- 2.17.1