[PATCH] exfat: implement "quiet" option for setattr

2020-06-27 Thread Park Ju Hyung
Few programs, especially old ones, simply don't want to work
if there isn't a POSIX-compliant setattr.

Follow vfat and implement a new "quiet" option to workaround this.

Signed-off-by: Park Ju Hyung 
---
 fs/exfat/exfat_fs.h |  2 ++
 fs/exfat/file.c | 13 +++--
 fs/exfat/super.c|  7 +++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
index 3aed8e22087a..66837baf42d2 100644
--- a/fs/exfat/exfat_fs.h
+++ b/fs/exfat/exfat_fs.h
@@ -201,6 +201,8 @@ struct exfat_mount_options {
unsigned short allow_utime;
/* charset for filename input/display */
char *iocharset;
+   /* fake return success on setattr(e.g. chmods/chowns) */
+   unsigned char quiet;
/* on error: continue, panic, remount-ro */
enum exfat_error_mode errors;
unsigned utf8:1, /* Use of UTF-8 character set */
diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 6707f3eb09b5..2ed6be7cab15 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -295,7 +295,7 @@ int exfat_setattr(struct dentry *dentry, struct iattr *attr)
attr->ia_size > i_size_read(inode)) {
error = exfat_cont_expand(inode, attr->ia_size);
if (error || attr->ia_valid == ATTR_SIZE)
-   return error;
+   goto out;
attr->ia_valid &= ~ATTR_SIZE;
}
 
@@ -309,8 +309,11 @@ int exfat_setattr(struct dentry *dentry, struct iattr 
*attr)
 
error = setattr_prepare(dentry, attr);
attr->ia_valid = ia_valid;
-   if (error)
+   if (error) {
+   if (sbi->options.quiet)
+   error = 0;
goto out;
+   }
 
if (((attr->ia_valid & ATTR_UID) &&
 !uid_eq(attr->ia_uid, sbi->options.fs_uid)) ||
@@ -322,6 +325,12 @@ int exfat_setattr(struct dentry *dentry, struct iattr 
*attr)
goto out;
}
 
+   if (error) {
+   if (sbi->options.quiet)
+   error = 0;
+   goto out;
+   }
+
/*
 * We don't return -EPERM here. Yes, strange, but this is too
 * old behavior.
diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index b5bf6dedbe11..030db33eed35 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -145,6 +145,8 @@ static int exfat_show_options(struct seq_file *m, struct 
dentry *root)
seq_printf(m, ",fmask=%04o,dmask=%04o", opts->fs_fmask, opts->fs_dmask);
if (opts->allow_utime)
seq_printf(m, ",allow_utime=%04o", opts->allow_utime);
+   if (opts->quiet)
+   seq_puts(m, ",quiet");
if (opts->utf8)
seq_puts(m, ",iocharset=utf8");
else if (sbi->nls_io)
@@ -198,6 +200,7 @@ enum {
Opt_fmask,
Opt_allow_utime,
Opt_charset,
+   Opt_quiet,
Opt_errors,
Opt_discard,
Opt_time_offset,
@@ -224,6 +227,7 @@ static const struct fs_parameter_spec exfat_parameters[] = {
fsparam_u32oct("fmask", Opt_fmask),
fsparam_u32oct("allow_utime",   Opt_allow_utime),
fsparam_string("iocharset", Opt_charset),
+   fsparam_flag("quiet",   Opt_quiet),
fsparam_enum("errors",  Opt_errors, exfat_param_enums),
fsparam_flag("discard", Opt_discard),
fsparam_s32("time_offset",  Opt_time_offset),
@@ -274,6 +278,9 @@ static int exfat_parse_param(struct fs_context *fc, struct 
fs_parameter *param)
opts->iocharset = param->string;
param->string = NULL;
break;
+   case Opt_quiet:
+   opts->quiet = 1;
+   break;
case Opt_errors:
opts->errors = result.uint_32;
break;
-- 
2.27.0



Re: [PATCH] staging: exfat: add exfat filesystem code to

2019-09-16 Thread Park Ju Hyung
On Tue, 17 Sep 2019 00:19:36 -0400, "Valdis Klētnieks" said:
> I'm working off a somewhat cleaned up copy of Samsung's original driver,
> because that's what I had knowledge of.  If the sdfat driver is closer to 
> being
> mergeable, I'd not object if that got merged instead.

Greg, as Valdis mentioned here, the staging tree driver is just another exFAT 
fork
from Samsung.
What's the point of using a much older driver?

sdFAT is clearly more matured and been put into more recent production 
softwares.
And as I wrote in previous email, it does include some real fixes.

As Namjae said too, Samsung would be more interested in merging sdFAT to 
upstream.
If we diverge, Samsung will have less reasons to contribute their patches to 
upstream.

Also, I think it makes much more sense to make Samsung the maintainer of this 
driver
(if they're willing to put in the manpower to do so). Asking them would be the 
first
step in doing so.

> But here's the problem... Samsung has their internal sdfat code, Park Yu Hyung
> has what appears to be a fork of that code from some point (and it's unclear ,
> and it's unclear which one has had more bugfixes and cleanups to get it to
> somewhere near mainline mergeable.

I made it extremely clear on where I took the code.

The initial commit: "sdfat: import from G973FXXU3ASG8" states which kernel 
source
I used.

You can simply search "G973FXXU3ASG8" on http://opensource.samsung.com and 
download
the source code. It'll match exactly with my initial commit.

My repository is basically rename + clean-up + older kernel compat.

I think we can all agree that using the sdFAT naming on non-Android is very
misleading, which is why I renamed it to exFAT.

sdFAT includes support for fat16/32, and as also mentioned in
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?h=staging-next=58985a9d2d03e977db93bf574a16162766a318fe
this isn't desirable, especially in mainline.
I cleaned it up and removed some other Samsung's code that relies on proprietary
userspace tools such as defrag.

I believe my repository is in the cleanest state for getting merged to mainline,
compared to other drivers avilable out there.

If we happen to pick it to mainline, I think it'll also be quite trivial for 
Samsung
to pick mainline patches back to their sdFAT drivers used in Galaxy devices.

> Can you provide a pointer to what Samsung is *currently* using? We probably
> need to stop and actually look at the code bases and see what's in the best
> shape currently.

Namjae could probably elaborate here, but if I were to guess, there wasn't a
noticeable difference in recent sdFAT releases. Even the lastest Note10 kernel 
only
had some uevent changes.

I think the current latest public source's driver is the best one available.

Thanks.


Re: [PATCH] staging: exfat: add exfat filesystem code to

2019-09-14 Thread Park Ju Hyung
Hi.

I just noticed that this exfat-staging drivers are based on the old 
Samsung's 1.x exFAT drivers.

I've been working to get the newer Samsung's driver(now named "sdFAT") 
to fit better for general Linux users, and I believe it can provide a 
better base for the community to work on(and hopefully complies better 
to the mainline coding standard).

GitHub link
https://github.com/arter97/exfat-linux

I also included some rudimentary benchmark results.

I encourage mainline developers to explore this driver base and see if 
it's worth to switch, since it's the early days of exfat-staging.

To others watching this thread:
It's more than likely that you can start using exFAT reliably right 
away by following the link above. It's tested on all major LTS kernels 
ranging from 3.4 to 4.19 and the ones Canonical uses for Ubuntu: 3.4, 
3.10, 3.18, 4.1, 4.4, 4.9, 4.14, 4.19 and 4.15, 5.0, 5.2, and 5.3-rc.

Thanks.