From patchwork Thu Oct 22 05:00:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1385926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=QCCVXoH1; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CGwDj4mVdz9sPB for ; Thu, 22 Oct 2020 16:01:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2507646AbgJVFBI (ORCPT ); Thu, 22 Oct 2020 01:01:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2507656AbgJVFBG (ORCPT ); Thu, 22 Oct 2020 01:01:06 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A702DC0613CE for ; Wed, 21 Oct 2020 22:01:05 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id i2so530755ljg.4 for ; Wed, 21 Oct 2020 22:01:05 -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=jFZ6u6ALdKbHLTZh8LIvvnB8ZJ6omGcOgYQuidf1NB8=; b=QCCVXoH1ZRsW0wtfFYU5JzVFEBrSxhNz7qA7ffYaH8CsQitHZsqBjtRny0ksWdrDXY 7y4aF1Ytd9zOcS1F4Jl0LlY+DttzMCyLQDqgscOGUCLK8DPhkBWZocw9UVW/O823pwrp pNxoZ5+KRecdD1KEESAhGT8r0D14X7+QX/yNhXQgTIPJQD6eXvwXwkoWrboe4BNhdRfB +fMpstkGm+N1gDkNVjaGMZs3x2Z4rRi0zxmqMCwDkem/BPDjcHdBC7H0eNkgmpo2GOB/ WAvW/hEdn8TbPNUwDho1cIw1EtcHjb6qzkVrG2Zw12CvRLtSxqnaoNUGb4qxPxqYvlhD xl/g== 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=jFZ6u6ALdKbHLTZh8LIvvnB8ZJ6omGcOgYQuidf1NB8=; b=H6mpsFO0lLVUsS8gk64PCGlXq4OUpi+Grr8xSJBhRlh15xGcPMYztcjrAbvOeNs1Fn rCFcwfZLPMjiU+JYsu192qBdVEp9TFznSj8FGwTziLCWUhpJd2Zpj4l+nRu/E5nvFlGC XgdVLG/aY/w+6gscGcMzmCdlAGerZn0g6MgKheyWglLIJ9NgS67hVWCa5+DStZrjLcCt SUQ2cAgQ1p7CvqOPRgCNh3FqLb7kXVzjw+Kk6Hp1I3wpEHHVUPkBkiDJjWUsq22a5mpP elRUik620QA3wcn0Z66a7wrs6cTpF1/y0j90xD2ag6W73+DI2aKK6BC5K86sppPhbz6Z 9vfQ== X-Gm-Message-State: AOAM532Sqhh1yBSkEew5iQl4dPN++NqI+jf4bq4a7wfC0n670gP7BP01 gjQwhpOzQ/7fAMxJmnFmx4clRaKvBym3I3cqdDpTsqzh6fxgaA== X-Google-Smtp-Source: ABdhPJwPFM+uXvhV2gqWo5uSOMeTqjGBStT+oFcfKoV5cUVPCm9AnrkzXVJeTSh5a26p6tebDhy6/otaXTgYU/KrwzA= X-Received: by 2002:a2e:b009:: with SMTP id y9mr280283ljk.372.1603342863818; Wed, 21 Oct 2020 22:01:03 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Thu, 22 Oct 2020 00:00:52 -0500 Message-ID: Subject: [PATCH]SMB3] Add support for WSL reparse tags To: CIFS , samba-technical Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org The IO_REPARSE_TAG_LX_ tags originally were used by WSL but they are preferred by the Linux client in some cases since, unlike the NFS reparse tag (or EAs), they don't require an extra query to determine which type of special file they represent. Add support for readdir to recognize special file types of FIFO, SOCKET, CHAR, BLOCK and SYMLINK. This can be tested by creating these special files in WSL Linux and then sharing that location on the Windows server and mounting to the Windows server to access them. Prior to this patch all of the special files would show up as being of type 'file' but with this patch they can be seen with the correct file type as can be seen below: brwxr-xr-x 1 root root 0, 0 Oct 21 17:10 block crwxr-xr-x 1 root root 0, 0 Oct 21 17:46 char drwxr-xr-x 2 root root 0 Oct 21 18:27 dir prwxr-xr-x 1 root root 0 Oct 21 16:21 fifo -rwxr-xr-x 1 root root 0 Oct 21 15:48 file lrwxr-xr-x 1 root root 0 Oct 21 15:52 symlink-to-file TODO: go through all documented reparse tags to see if we can reasonably map some of them to directories vs. files vs. symlinks Reviewed-by: Aurelien Aptel From d9dc8174f13f7b437d9670a84ca8d41fc2110063 Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 21 Oct 2020 23:54:19 -0500 Subject: [PATCH] SMB3: add support for recognizing WSL reparse tags The IO_REPARSE_TAG_LX_ tags originally were used by WSL but they are preferred by the Linux client in some cases since, unlike the NFS reparse tag (or EAs), they don't require an extra query to determine which type of special file they represent. Add support for readdir to recognize special file types of FIFO, SOCKET, CHAR, BLOCK and SYMLINK. This can be tested by creating these special files in WSL Linux and then sharing that location on the Windows server and mounting to the Windows server to access them. Prior to this patch all of the special files would show up as being of type 'file' but with this patch they can be seen with the correct file type as can be seen below: brwxr-xr-x 1 root root 0, 0 Oct 21 17:10 block crwxr-xr-x 1 root root 0, 0 Oct 21 17:46 char drwxr-xr-x 2 root root 0 Oct 21 18:27 dir prwxr-xr-x 1 root root 0 Oct 21 16:21 fifo -rwxr-xr-x 1 root root 0 Oct 21 15:48 file lrwxr-xr-x 1 root root 0 Oct 21 15:52 symlink-to-file TODO: go through all documented reparse tags to see if we can reasonably map some of them to directories vs. files vs. symlinks Signed-off-by: Steve French --- fs/cifs/readdir.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 5abf1ea21abe..799be3a5d25e 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -168,10 +168,33 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb) fattr->cf_uid = cifs_sb->mnt_uid; fattr->cf_gid = cifs_sb->mnt_gid; + /* + * The IO_REPARSE_TAG_LX_ tags originally were used by WSL but they + * are preferred by the Linux client in some cases since, unlike + * the NFS reparse tag (or EAs), they don't require an extra query + * to determine which type of special file they represent. + * TODO: go through all documented reparse tags to see if we can + * reasonably map some of them to directories vs. files vs. symlinks + */ if (fattr->cf_cifsattrs & ATTR_DIRECTORY) { fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode; fattr->cf_dtype = DT_DIR; - } else { + } else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_SYMLINK) { + fattr->cf_mode |= S_IFLNK | cifs_sb->mnt_file_mode; + fattr->cf_dtype = DT_LNK; + } else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_FIFO) { + fattr->cf_mode |= S_IFIFO | cifs_sb->mnt_file_mode; + fattr->cf_dtype = DT_FIFO; + } else if (fattr->cf_cifstag == IO_REPARSE_TAG_AF_UNIX) { + fattr->cf_mode |= S_IFSOCK | cifs_sb->mnt_file_mode; + fattr->cf_dtype = DT_SOCK; + } else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_CHR) { + fattr->cf_mode |= S_IFCHR | cifs_sb->mnt_file_mode; + fattr->cf_dtype = DT_CHR; + } else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_BLK) { + fattr->cf_mode |= S_IFBLK | cifs_sb->mnt_file_mode; + fattr->cf_dtype = DT_BLK; + } else { /* TODO: should we mark some other reparse points (like DFSR) as directories? */ fattr->cf_mode = S_IFREG | cifs_sb->mnt_file_mode; fattr->cf_dtype = DT_REG; } -- 2.25.1