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

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

Post by Phillip Su » Mon, 06 Mar 2006 04:40:16


his patch fixes a bug in udf where it would write uid/gid = 0 to the
disk for files owned by the id given with the uid=/gid= mount options.
It also adds 4 new mount options: uid/gid=forget and uid/gid=ignore.
Without any options the id in core and on disk always match. Giving
uid/gid=nnn specifies a default ID to be used in core when the on disk ID
is -1. uid/gid=ignore forces the in core ID to allways be used no matter
what the on disk ID is. uid/gid=forget forces the on disk ID to always be
written out as -1.

The use of these options allows you to override ownerships on a disk or
disable ownwership information from being written, allowing the media
to be used portably between different computers and possibly different users
without permissions issues that would require root to correct.

Signed-off-by: Phillip Susi < XXXX@XXXXX.COM >

---

fs/udf/inode.c | 14 ++++++++++----
fs/udf/super.c | 18 +++++++++++++++++-
fs/udf/udf_sb.h | 4 ++++
3 files changed, 31 insertions(+), 5 deletions(-)

2428c90c6e52a317808896b6cd639199388f7ddd
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 395e582..2f47bf6 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1045,10 +1045,12 @@ static void udf_fill_inode(struct inode
}

inode->i_uid = le32_to_cpu(fe->uid);
- if ( inode->i_uid == -1 ) inode->i_uid = UDF_SB(inode->i_sb)->s_uid;
+ if ( inode->i_uid == -1 || UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) )
+ inode->i_uid = UDF_SB(inode->i_sb)->s_uid;

inode->i_gid = le32_to_cpu(fe->gid);
- if ( inode->i_gid == -1 ) inode->i_gid = UDF_SB(inode->i_sb)->s_gid;
+ if ( inode->i_gid == -1 || UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) )
+ inode->i_gid = UDF_SB(inode->i_sb)->s_gid;

inode->i_nlink = le16_to_cpu(fe->fileLinkCount);
if (!inode->i_nlink)
@@ -1335,10 +1337,14 @@ udf_update_inode(struct inode *inode, in
return err;
}

- if (inode->i_uid != UDF_SB(inode->i_sb)->s_uid)
+ 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);

- if (inode->i_gid != UDF_SB(inode->i_sb)->s_gid)
+ 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);

udfperms = ((inode->i_mode & S_IRWXO) ) |
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 4a6f49a..368d8f8 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -269,7 +269,7 @@ enum {
Opt_gid, Opt_uid, Opt_umask, Opt_session, Opt_lastblock,
Opt_anchor, Opt_volume, Opt_partition, Opt_fileset,
Opt_rootdir, Opt_utf8, Opt_iocharset,
- Opt_err
+ Opt_err, Opt_uforget, Opt_uignore, Opt_gforget, Opt_gignore
};

static match_table_t tokens = {
@@ -282,6 +282,10 @@ static match_table_t tokens = {
{Opt_adinicb, "adinicb"},
{Opt_shortad, "shortad"},
{Opt_longad, "longad"},
+ {Opt_uforget, "uid=forget"},
+ {Opt_uignore, "uid=ignore"},
+ {Opt_gforget, "gid=forget"},
+ {Opt_gignore, "gid=ignore"},
{Opt_gid, "gid=%u"},
{Opt_uid, "uid=%u"},
{Opt_umask, "umask=%o"},
@@ -414,6 +418,18 @@ udf_parse_options(char *options, struct
uopt->flags |= (1 << UDF_FLAG_NLS_MAP);
break;
#endif
+ case Opt_uignore:
+
 
 
 

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

Post by Phillip Su » Tue, 07 Mar 2006 10:20:11

ekka Enberg wrote:

My bad, I meant to remove those ifs, not just prepend them with an else. Try this one:

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

This patch fixes a bug in udf where it would write uid/gid = 0 to the
disk for files owned by the id given with the uid=/gid= mount options.
It also adds 4 new mount options: uid/gid=forget and uid/gid=ignore.
Without any options the id in core and on disk always match. Giving
uid/gid=nnn specifies a default ID to be used in core when the on disk ID
is -1. uid/gid=ignore forces the in core ID to allways be used no matter
what the on disk ID is. uid/gid=forget forces the on disk ID to always be
written out as -1.

The use of these options allows you to override ownerships on a disk or
disable ownwership information from being written, allowing the media
to be used portably between different computers and possibly different users
without permissions issues that would require root to correct.

Signed-off-by: Phillip Susi < XXXX@XXXXX.COM >

---

fs/udf/inode.c | 18 +++++++++++-------
fs/udf/super.c | 18 +++++++++++++++++-
fs/udf/udf_sb.h | 4 ++++
3 files changed, 32 insertions(+), 8 deletions(-)

c8393f6e4fe6159fd916f3c68091e76bbfdc5fd8
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 395e582..49aeac3 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1045,10 +1045,12 @@ static void udf_fill_inode(struct inode
}

inode->i_uid = le32_to_cpu(fe->uid);
- if ( inode->i_uid == -1 ) inode->i_uid = UDF_SB(inode->i_sb)->s_uid;
+ if ( inode->i_uid == -1 || UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) )
+ inode->i_uid = UDF_SB(inode->i_sb)->s_uid;

inode->i_gid = le32_to_cpu(fe->gid);
- if ( inode->i_gid == -1 ) inode->i_gid = UDF_SB(inode->i_sb)->s_gid;
+ if ( inode->i_gid == -1 || UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) )
+ inode->i_gid = UDF_SB(inode->i_sb)->s_gid;

inode->i_nlink = le16_to_cpu(fe->fileLinkCount);
if (!inode->i_nlink)
@@ -1335,11 +1337,13 @@ udf_update_inode(struct inode *inode, in
return err;
}

- if (inode->i_uid != UDF_SB(inode->i_sb)->s_uid)
- fe->uid = cpu_to_le32(inode->i_uid);
-
- if (inode->i_gid != UDF_SB(inode->i_sb)->s_gid)
- fe->gid = cpu_to_le32(inode->i_gid);
+ if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET))
+ fe->uid = cpu_to_le32(-1);
+ 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 fe->gid = cpu_to_le32(inode->i_gid);

udfperms = ((inode->i_mode & S_IRWXO) ) |
((inode->i_mode & S_IRWXG) << 2) |
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 4a6f49a..368d8f8 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -269,7 +269,7 @@ enum {
Opt_gid, Opt_uid, Opt_umask, Opt_session, Opt_lastblock,
Opt_anchor, Opt_volume, Opt_partition, Opt_fileset,
Opt_rootdir, Opt_utf8, Opt_iocharset,
- Opt_err
+ Opt_err, Opt_uforget, Opt_uignore, Opt_gforget, Opt_gignore
};

static match_table_t tokens = {
@@ -282,6 +282,10 @@ static match_table_t tokens = {
{Opt_adinicb, "adinicb"},
{Opt_shortad, "shortad"},
{Opt_longad, "longad"},
+ {Opt_uforget, "uid=forget"},
+ {Opt_uignore, "uid=ignore"},
+ {Opt_gforget, "gid=forget"},
+ {Opt_g
 
 
 

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

Post by Phillip Su » Wed, 08 Mar 2006 12:30:08


What exactly do you mean by formatting?


Yes, if you chown a file that is owned by -1 on disk, you do want it to
be saved back with the new id, unless you set the forget option.


You mean use hard tabstops instead of two spaces to indent? Is there a
way to set emacs to do that? It automatically uses the two spaces.


Working on it.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
 
 
 

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

Post by Phillip Su » Thu, 09 Mar 2006 01:00:24


Wow! 8 spaces? I always go with 4, 8 wastes way too much screen space.
Is there a handy incantation to get emacs to auto indent with a hard
tab rather than 2 spaces like it does by default?


I wrote up some docs for it last night.


Hrm... I'll take a look at that tonight and see what I come up with.
Probably will resubmit the patch tomorrow.



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
 
 
 

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

Post by Phillip Su » Wed, 22 Mar 2006 01:30:21


See http://www.yqcomputer.com/


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.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/