Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Mar 2013 22:21:38 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        "Kenneth D. Merry" <ken@FreeBSD.org>
Cc:        arch@FreeBSD.org, fs@FreeBSD.org
Subject:   Re: patches to add new stat(2) file flags
Message-ID:  <20130307214649.X981@besplex.bde.org>
In-Reply-To: <20130307000533.GA38950@nargothrond.kdm.org>
References:  <20130307000533.GA38950@nargothrond.kdm.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 6 Mar 2013, Kenneth D. Merry wrote:

> I have attached diffs against head for some additional stat(2) file flags.
>
> The primary purpose of these flags is to improve compatibility with CIFS,
> both from the client and the server side.
> ...
> 	UF_IMMUTABLE:	Command line name: "uchg", "uimmutable"
> 			ZFS name: XAT_READONLY, ZFS_READONLY
> 			Windows: FILE_ATTRIBUTE_READONLY
>
> 			This flag means that the file may not be modified.
> 			This is not a new flag, but where applicable it is
> 			mapped to the Windows readonly bit.  ZFS and UFS
> 			now both support the flag and enforce it.
>
> 			The behavior of this flag is compatible with MacOS X.

This is incompatible with mapping the DOS read-only attribute to the
non-writeable file permission in msdosfs.  msdosfs does this mainly to
get at least one useful file permission, but the semantics are subtly
different from all of file permissions, UF_IMMUTABLE and SF_IMMUTABLE.
I think it should be a new flag.

> 	SF_ARCHIVED:	Command line name: "arch", "archived"
> 			ZFS_NAME: XAT_ARCHIVE, ZFS_ARCHIVE
> 			Windows name: FILE_ATTRIBUTE_ARCHIVE
>
> 			The SF_ARCHIVED flag means that the file has been
> 			archived.  The meaning is the inverse of the Windows
> 			FILE_ATTRIBUTE_ARCHIVE, and the ZFS XAT_ARCHIVE and
> 			ZFS_ARCHIVE attribute.  Accordingly, we invert the
> 			internal flags in ZFS and SMBFS to get the value of
> 			SF_ARCHIVED.

msdosfs inverts this too.  Another problem with it is that (I think)
changing it is not a privileged operation in WinDOS, so it should be
mapped to UF_ARCHIVE and not reversed.  Since you are adding lots of
flags, you could easily fix this.  You made all the new flags UF_*.
Even removal of SF_ARCHIVED wouldn't be missed, since ffs doesn't
maintain it and no FreeBSD utility in /usr/src supports it (except to
change and print it).

> 	msdosfs_vnops.c:	Add support for getting and setting
> 				UF_HIDDEN and UF_SYSTEM in MSDOSFS.

There is also a PR that maps the SYSTEM attribute to SF_IMMUTABLE.  That
would be useful but I think it is not orthogonal enough, and SF_IMMUTABLE
is probably too strict.  Mapping it to UF_SYSTEM ...

> 				It already supports SF_ARCHIVED.  It
> 				currently supports the readonly bit with
> 				standard Unix permissions, but could be
> 				extended to support UF_IMMUTABLE.

... and not mapping READONLY leaves no mapping to an immutable bit.  If
you map READONLY to a new flag, it can still be used to give a certain
amount of immutability that is weaker than [US]F_IMMUTABLE.  Under
FreeBSD, the immutable flags prevent changing anything, but under WinXP,
I didn't notice the READONLY attribute preventing Cygwin (on ntfs and
FAT32 file systems) changing things like acls and times, but that might
be because Cygwin works around what it considers excessive security.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130307214649.X981>