2006-03-20 02:32:37

by Phillip Susi

[permalink] [raw]
Subject: [PATCH] udf: fix uid/gid options and add uid/gid=ignore and forget options

This patch corrects the incorrect patch previously applied in
commit 4d6660eb3665f22d16aff466eb9d45df6102b254. I had posted
the correction as a reply on lkml, but it seems that the earlier
and incorrect patch got merged into Linus's tree. This patch
also adds documentation for the changes made last time.

---

Documentation/filesystems/udf.txt | 14 ++++++++++++++
fs/udf/inode.c | 6 ++----
2 files changed, 16 insertions(+), 4 deletions(-)

83a730fb2e864dae308008d83c5d804afc539f08
diff --git a/Documentation/filesystems/udf.txt b/Documentation/filesystems/udf.txt
index e5213bc..85ff288 100644
--- a/Documentation/filesystems/udf.txt
+++ b/Documentation/filesystems/udf.txt
@@ -26,6 +26,20 @@ The following mount options are supporte
nostrict Unset strict conformance
iocharset= Set the NLS character set

+The uid= and gid= options need a bit more explaining. They will accept a
+decimal numeric value which will be used as the default ID for that mount.
+They will also accept the string "ignore" and "forget". For files on the disk
+that are owned by nobody ( -1 ), they will instead look as if they are owned
+by the default ID. The ignore option causes the default ID to override all
+IDs on the disk, not just -1. The forget option causes all IDs to be written
+to disk as -1, so when the media is later remounted, they will appear to be
+owned by whatever default ID it is mounted with at that time.
+
+For typical desktop use of removable media, you should set the ID to that
+of the interactively logged on user, and also specify both the forget and
+ignore options. This way the interactive user will always see the files
+on the disk as belonging to him.
+
The remaining are for debugging and disaster recovery:

novrs Skip volume sequence recognition
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index d04cff2..81e0e84 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1341,13 +1341,11 @@ udf_update_inode(struct inode *inode, in

if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET))
fe->uid = cpu_to_le32(-1);
- else if (inode->i_uid != UDF_SB(inode->i_sb)->s_uid)
- fe->uid = cpu_to_le32(inode->i_uid);
+ else fe->uid = cpu_to_le32(inode->i_uid);

if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET))
fe->gid = cpu_to_le32(-1);
- else if (inode->i_gid != UDF_SB(inode->i_sb)->s_gid)
- fe->gid = cpu_to_le32(inode->i_gid);
+ else fe->gid = cpu_to_le32(inode->i_gid);

udfperms = ((inode->i_mode & S_IRWXO) ) |
((inode->i_mode & S_IRWXG) << 2) |
--
1.1.3


2006-03-20 04:07:31

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] udf: fix uid/gid options and add uid/gid=ignore and forget options

Phillip Susi <[email protected]> wrote:
>
> This patch corrects the incorrect patch previously applied in
> commit 4d6660eb3665f22d16aff466eb9d45df6102b254. I had posted
> the correction as a reply on lkml, but it seems that the earlier
> and incorrect patch got merged into Linus's tree.

I didn't see that update, and I don't miss much.

> --- a/fs/udf/inode.c
> +++ b/fs/udf/inode.c
> @@ -1341,13 +1341,11 @@ udf_update_inode(struct inode *inode, in
>
> if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET))
> fe->uid = cpu_to_le32(-1);
> - else if (inode->i_uid != UDF_SB(inode->i_sb)->s_uid)
> - fe->uid = cpu_to_le32(inode->i_uid);
> + else fe->uid = cpu_to_le32(inode->i_uid);
>
> if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET))
> fe->gid = cpu_to_le32(-1);
> - else if (inode->i_gid != UDF_SB(inode->i_sb)->s_gid)
> - fe->gid = cpu_to_le32(inode->i_gid);
> + else fe->gid = cpu_to_le32(inode->i_gid);
>
> udfperms = ((inode->i_mode & S_IRWXO) ) |
> ((inode->i_mode & S_IRWXG) << 2) |

This is an unchangelogged alteration.

Please provide a description of this change. What problem is it fixing?
How does it fix it? What are the consequences of not making this change?

Thanks.

2006-03-20 16:27:28

by Phillip Susi

[permalink] [raw]
Subject: Re: [PATCH] udf: fix uid/gid options and add uid/gid=ignore and forget options

Andrew Morton wrote:
> I didn't see that update, and I don't miss much.
>

See http://lkml.org/lkml/2006/3/5/171

> Please provide a description of this change. What problem is it fixing?
> How does it fix it? What are the consequences of not making this change?

In the initial patch I made a typo. As Pekka Enberg pointed out, with
the if still following the else, you can still get a null uid written to
the disk if you specify a default uid= without uid=forget. In other
words, if the desktop user is uid=1000 and the mount option uid=1000 is
given ( which is done on ubuntu automatically and probably other
distributions that use hal ), then if any other user besides uid 1000
owns a file then a 0 will be written to the media as the owning uid
instead. This is exactly what the original patch was trying to prevent.