RE: [PATCH v2 2/2] f2fs: Advertise encrypted casefolding in sysfs

From: David Laight
Date: Fri Jun 04 2021 - 04:27:38 EST


From: Jaegeuk Kim
> Sent: 04 June 2021 05:45
...
> > > @@ -161,6 +161,9 @@ static ssize_t features_show(struct f2fs_attr *a,
> > > if (f2fs_sb_has_compression(sbi))
> > > len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
> > > len ? ", " : "", "compression");
> > > + if (f2fs_sb_has_casefold(sbi) && f2fs_sb_has_encrypt(sbi))
> > > + len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
> > > + len ? ", " : "", "encrypted_casefold");
> > > len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
> > > len ? ", " : "", "pin_file");
> > > len += scnprintf(buf + len, PAGE_SIZE - len, "\n");

Looking at that pattern, why don't you just append "tag, "
each time and then replace the final ", " with "\n" at the end.

Although if I wanted to quickly parse that in (say) a shell
script I wouldn't really want the ",".
OTOH it is too late to change that.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)