ntfs3.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Daniel Pinto <danielpinto52@gmail.com>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
	ntfs3@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 2/3] fs/ntfs3: Add hidedotfiles option
Date: Mon, 3 Oct 2022 23:51:25 +0100	[thread overview]
Message-ID: <3be00e03-2aa9-0b7c-40e4-e3dfecb05ad5@gmail.com> (raw)
In-Reply-To: <1194d7b9-658f-b724-93d4-2f2b02b569ca@paragon-software.com>



Às 17:40 de 12/09/22, Konstantin Komarov escreveu:
> With this option all files with filename[0] == '.'
> will have FILE_ATTRIBUTE_HIDDEN attribute.
> 
> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
> ---
>  fs/ntfs3/inode.c   | 4 ++++
>  fs/ntfs3/ntfs_fs.h | 1 +
>  fs/ntfs3/super.c   | 5 +++++
>  3 files changed, 10 insertions(+)
> 
> diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
> index 51363d4e8636..40b8565815a2 100644
> --- a/fs/ntfs3/inode.c
> +++ b/fs/ntfs3/inode.c
> @@ -1257,6 +1257,10 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
>          fa = FILE_ATTRIBUTE_ARCHIVE;
>      }
>  
> +    /* If option "hidedotfiles" then set hidden attribute for dot files. */
> +    if (sbi->options->hide_dot_files && name->name[0] == '.')
> +        fa |= FILE_ATTRIBUTE_HIDDEN;
> +
>      if (!(mode & 0222))
>          fa |= FILE_ATTRIBUTE_READONLY;
>  
> diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
> index 2c791222c4e2..cd680ada50ab 100644
> --- a/fs/ntfs3/ntfs_fs.h
> +++ b/fs/ntfs3/ntfs_fs.h
> @@ -97,6 +97,7 @@ struct ntfs_mount_options {
>      unsigned sparse : 1; /* Create sparse files. */
>      unsigned showmeta : 1; /* Show meta files. */
>      unsigned nohidden : 1; /* Do not show hidden files. */
> +    unsigned hide_dot_files : 1; /* Set hidden flag on dot files. */
>      unsigned force : 1; /* RW mount dirty volume. */
>      unsigned noacsrules : 1; /* Exclude acs rules. */
>      unsigned prealloc : 1; /* Preallocate space when file is growing. */
> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> index 86ff55133faf..067a0e9cf590 100644
> --- a/fs/ntfs3/super.c
> +++ b/fs/ntfs3/super.c
> @@ -247,6 +247,7 @@ enum Opt {
>      Opt_force,
>      Opt_sparse,
>      Opt_nohidden,
> +    Opt_hide_dot_files,
>      Opt_showmeta,
>      Opt_acl,
>      Opt_iocharset,
> @@ -266,6 +267,7 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = {
>      fsparam_flag_no("force",        Opt_force),
>      fsparam_flag_no("sparse",        Opt_sparse),
>      fsparam_flag_no("hidden",        Opt_nohidden),
> +    fsparam_flag_no("hidedotfiles",        Opt_hide_dot_files),
>      fsparam_flag_no("acl",            Opt_acl),
>      fsparam_flag_no("showmeta",        Opt_showmeta),
>      fsparam_flag_no("prealloc",        Opt_prealloc),
> @@ -357,6 +359,9 @@ static int ntfs_fs_parse_param(struct fs_context *fc,
>      case Opt_nohidden:
>          opts->nohidden = result.negated ? 1 : 0;
>          break;
> +    case Opt_hide_dot_files:
> +        opts->hide_dot_files = result.negated ? 1 : 0;

I believe the 0 and 1 should be switched here. With the code as it is, the behaviour is
the reverse of what is expected: the hidedotfiles mount option disables setting the hidden
attribute and the nohidedotfiles enables it.

> +        break;
>      case Opt_acl:
>          if (!result.negated)
>  #ifdef CONFIG_NTFS3_FS_POSIX_ACL

Hello,

I have found a bug in your patch. I explained it above. Also, the patch will only set the 
hidden attribute when a new file or directory is created. It will not set it (or unset it)
when files or directories are moved or renamed.

Best regards,
Daniel Pinto

  reply	other threads:[~2022-10-03 22:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12 16:37 [PATCH 0/3] fs/ntfs3: Refactoring and hidedotfiles option Konstantin Komarov
2022-09-12 16:39 ` [PATCH 1/3] fs/ntfs3: Add comments about cluster size Konstantin Komarov
2022-09-12 16:40 ` [PATCH 2/3] fs/ntfs3: Add hidedotfiles option Konstantin Komarov
2022-10-03 22:51   ` Daniel Pinto [this message]
2022-09-12 16:40 ` [PATCH 3/3] fs/ntfs3: Change destroy_inode to free_inode Konstantin Komarov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3be00e03-2aa9-0b7c-40e4-e3dfecb05ad5@gmail.com \
    --to=danielpinto52@gmail.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).