public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Hamish Moffatt <hamish@cloud.net.au>
To: linux-mtd@lists.infradead.org
Subject: [PATCH] mkfs.ubifs: support --squash-uids
Date: Fri, 2 May 2008 15:16:55 +1000	[thread overview]
Message-ID: <20080502051655.GA6654@cloud.net.au> (raw)

mkfs.jffs2 and genext2fs both have a -U/--squash-uids switch which make
them ignore the uid/gids in the directory and set them to 0:0 instead.

Here's my implementation for mkfs.ubifs.

Signed-off-by: Hamish Moffatt <hamish@cloud.net.au>

--
Those tools also have a -P/--squash-perms switch which I haven't
implemented due to lack of need.

Index: mkfs.ubifs/mkfs.ubifs.c
===================================================================
--- mkfs.ubifs/mkfs.ubifs.c	(revision 4400)
+++ mkfs.ubifs/mkfs.ubifs.c	(working copy)
@@ -98,6 +98,7 @@
 static struct stat root_st;
 static char *output;
 static int out_fd;
+static int squash_owner;
 
 /* The 'head' (position) which nodes are written */
 static int head_lnum;
@@ -120,7 +121,7 @@
 /* Inode creation sequence number */
 static unsigned long long creat_sqnum;
 
-static const char *optstring = "d:r:m:o:D:h?vVe:c:g:f:p:k:x:j:l:j:";
+static const char *optstring = "d:r:m:o:D:h?vVe:c:g:f:p:k:x:j:l:j:U";
 
 static const struct option longopts[] = {
 	{"root"        , 1, NULL, 'r'},
@@ -139,6 +140,7 @@
 	{"keyhash"     , 1, NULL, 'k'},
 	{"log-lebs"    , 1, NULL, 'l'},
 	{"orph-lebs"   , 1, NULL, 'p'},
+	{"squash-uids" , 0, NULL, 'U'},
 	{NULL, 0, NULL, 0}
 };
 
@@ -159,6 +161,7 @@
 "  -l, --log-lebs=COUNT    Use COUNT erase blocks for the log\n"
 "  -p, --orph-lebs=COUNT   Use COUNT erase blocks for orphans (default: 1)\n"
 "  -D, --devtable=FILE     Use device table FILE\n"
+"  -U, --squash-uids       Squash owners making all files owned by root\n"
 "  -v, --verbose           Verbose operation\n"
 "  -V, --version           Display version information\n"
 "  -g, --debug=LEVEL       Display debug information (0 - none, 1 - statistics,\n"
@@ -509,6 +512,9 @@
 			if (c->max_bud_bytes < 0)
 				return -1;
 			break;
+		case 'U':
+			squash_owner = 1;
+			break;
 		}
 	}
 
@@ -885,8 +891,8 @@
 	ino->atime.sec  = cpu_to_le32(st->st_atime);
 	ino->ctime.sec  = cpu_to_le32(st->st_ctime);
 	ino->mtime.sec  = cpu_to_le32(st->st_mtime);
-	ino->uid        = cpu_to_le32(st->st_uid);
-	ino->gid        = cpu_to_le32(st->st_gid);
+	ino->uid        = cpu_to_le32((squash_owner) ? 0 : st->st_uid);
+	ino->gid        = cpu_to_le32((squash_owner) ? 0 : st->st_gid);
 	ino->mode       = cpu_to_le32(st->st_mode);
 	ino->flags      = cpu_to_le32(use_flags);
 	ino->data_len   = cpu_to_le32(data_len);
-- 
Hamish Moffatt VK3SB <hamish@debian.org> <hamish@cloud.net.au>

             reply	other threads:[~2008-05-02  5:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-02  5:16 Hamish Moffatt [this message]
2008-05-05  7:31 ` [PATCH] mkfs.ubifs: support --squash-uids Artem Bityutskiy
2008-05-05  8:46   ` Hamish Moffatt
2008-05-05  8:52     ` Artem Bityutskiy
2008-05-06 11:00       ` Artem Bityutskiy
2008-05-06  6:38     ` Artem Bityutskiy
2008-05-06  9:46       ` Hamish Moffatt
2008-05-06 10:23         ` Artem Bityutskiy
2008-05-08  0:16           ` Hamish Moffatt
2008-05-08  6:34             ` Artem Bityutskiy
2008-05-07 12:55         ` Artem Bityutskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080502051655.GA6654@cloud.net.au \
    --to=hamish@cloud.net.au \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox