linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Holler <holler@ahsoftware.de>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Alexander Holler <holler@ahsoftware.de>
Subject: [PATCH 4/5] WIP: Add patch for coreutils to support unlinkat_s (x86_64 only)
Date: Mon,  2 Feb 2015 18:05:12 +0100	[thread overview]
Message-ID: <1422896713-25367-5-git-send-email-holler@ahsoftware.de> (raw)
In-Reply-To: <1422896713-25367-1-git-send-email-holler@ahsoftware.de>

You have to build the new rm yourself

Signed-off-by: Alexander Holler <holler@ahsoftware.de>
---
 ...ion-s-to-rm-to-support-unlinkat_s-current.patch | 111 +++++++++++++++++++++
 1 file changed, 111 insertions(+)
 create mode 100644 0001-WIP-Add-option-s-to-rm-to-support-unlinkat_s-current.patch

diff --git a/0001-WIP-Add-option-s-to-rm-to-support-unlinkat_s-current.patch b/0001-WIP-Add-option-s-to-rm-to-support-unlinkat_s-current.patch
new file mode 100644
index 0000000..268cf56
--- /dev/null
+++ b/0001-WIP-Add-option-s-to-rm-to-support-unlinkat_s-current.patch
@@ -0,0 +1,111 @@
+From b4df97b5199e3fe7563a6e83a36fae031ee4777d Mon Sep 17 00:00:00 2001
+From: Alexander Holler <holler@ahsoftware.de>
+Date: Mon, 2 Feb 2015 16:59:24 +0100
+Subject: [PATCH] WIP: Add option -s to rm to support unlinkat_s() (currently
+ x86_64 only)
+
+Signed-off-by: Alexander Holler <holler@ahsoftware.de>
+---
+ src/mv.c     | 1 +
+ src/remove.c | 9 ++++++++-
+ src/remove.h | 3 +++
+ src/rm.c     | 9 ++++++++-
+ 4 files changed, 20 insertions(+), 2 deletions(-)
+
+diff --git a/src/mv.c b/src/mv.c
+index 0bcc1bb..03d3417 100644
+--- a/src/mv.c
++++ b/src/mv.c
+@@ -76,6 +76,7 @@ rm_option_init (struct rm_options *x)
+   x->ignore_missing_files = false;
+   x->remove_empty_directories = true;
+   x->recursive = true;
++  x->secure = false;
+   x->one_file_system = false;
+ 
+   /* Should we prompt for removal, too?  No.  Prompting for the 'move'
+diff --git a/src/remove.c b/src/remove.c
+index db8f993..a97e72c 100644
+--- a/src/remove.c
++++ b/src/remove.c
+@@ -367,7 +367,14 @@ static enum RM_status
+ excise (FTS *fts, FTSENT *ent, struct rm_options const *x, bool is_dir)
+ {
+   int flag = is_dir ? AT_REMOVEDIR : 0;
+-  if (unlinkat (fts->fts_cwd_fd, ent->fts_accpath, flag) == 0)
++  int rc;
++#ifdef __x86_64__
++  if (x->secure)
++    rc = syscall (322, fts->fts_cwd_fd, ent->fts_accpath, flag); // x86_64
++  else
++#endif
++    rc = unlinkat (fts->fts_cwd_fd, ent->fts_accpath, flag);
++  if (rc == 0)
+     {
+       if (x->verbose)
+         {
+diff --git a/src/remove.h b/src/remove.h
+index a450192..530b70b 100644
+--- a/src/remove.h
++++ b/src/remove.h
+@@ -49,6 +49,9 @@ struct rm_options
+   /* If true, recursively remove directories.  */
+   bool recursive;
+ 
++  /* If true, use unlinkat_s(). */
++  bool secure;
++
+   /* If true, remove empty directories.  */
+   bool remove_empty_directories;
+ 
+diff --git a/src/rm.c b/src/rm.c
+index c1a23d5..c061579 100644
+--- a/src/rm.c
++++ b/src/rm.c
+@@ -77,6 +77,7 @@ static struct option const long_opts[] =
+   {"-presume-input-tty", no_argument, NULL, PRESUME_INPUT_TTY_OPTION},
+ 
+   {"recursive", no_argument, NULL, 'r'},
++  {"secure", no_argument, NULL, 's'},
+   {"dir", no_argument, NULL, 'd'},
+   {"verbose", no_argument, NULL, 'v'},
+   {GETOPT_HELP_OPTION_DECL},
+@@ -155,6 +156,7 @@ Remove (unlink) the FILE(s).\n\
+       --no-preserve-root  do not treat '/' specially\n\
+       --preserve-root   do not remove '/' (default)\n\
+   -r, -R, --recursive   remove directories and their contents recursively\n\
++  -s, --secure          securely (use unlinkat_s)\n\
+   -d, --dir             remove empty directories\n\
+   -v, --verbose         explain what is being done\n\
+ "), stdout);
+@@ -193,6 +195,7 @@ rm_option_init (struct rm_options *x)
+   x->one_file_system = false;
+   x->remove_empty_directories = false;
+   x->recursive = false;
++  x->secure = false;
+   x->root_dev_ino = NULL;
+   x->stdin_tty = isatty (STDIN_FILENO);
+   x->verbose = false;
+@@ -223,7 +226,7 @@ main (int argc, char **argv)
+   /* Try to disable the ability to unlink a directory.  */
+   priv_set_remove_linkdir ();
+ 
+-  while ((c = getopt_long (argc, argv, "dfirvIR", long_opts, NULL)) != -1)
++  while ((c = getopt_long (argc, argv, "dfirsvIR", long_opts, NULL)) != -1)
+     {
+       switch (c)
+         {
+@@ -254,6 +257,10 @@ main (int argc, char **argv)
+           x.recursive = true;
+           break;
+ 
++        case 's':
++          x.secure = true;
++          break;
++
+         case INTERACTIVE_OPTION:
+           {
+             int i;
+-- 
+2.1.0
+
-- 
2.1.0

  parent reply	other threads:[~2015-02-02 17:05 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-02 17:05 [PATCH 0/5] RFC: Offer a way for userspace to request real deletion of files Alexander Holler
2015-02-02 17:05 ` [PATCH 1/5] WIP: Add syscall unlinkat_s (currently x86* only) Alexander Holler
2015-02-03  6:05   ` Al Viro
2015-02-03  6:58     ` Alexander Holler
2015-02-03  7:56       ` Al Viro
2015-02-03  8:01         ` Alexander Holler
2015-02-03  8:10           ` Al Viro
2015-02-03  8:17             ` Alexander Holler
2015-02-03  8:51         ` Alexander Holler
2015-02-03  9:23           ` Alexander Holler
2015-02-03 12:48             ` Alexander Holler
2015-02-03 12:54               ` Alexander Holler
2015-02-03 17:48               ` Theodore Ts'o
2015-02-03 18:01                 ` Alexander Holler
2015-02-03 23:33                   ` Al Viro
2015-02-04  0:18                     ` Alex Elsayed
2015-02-04  4:16                     ` Andreas Dilger
2015-02-04 10:19                     ` Alexander Holler
2015-02-04 12:07                       ` Lukáš Czerner
2015-02-04 12:22                         ` Alexander Holler
2015-02-04 12:42                           ` Alexander Holler
2015-02-04 12:50                             ` Alexander Holler
2015-02-04 13:07                               ` Alexander Holler
2015-02-04 13:06                           ` Michael Kerrisk
2015-02-04 13:21                             ` Alexander Holler
     [not found]                               ` <54D21CC8.4020705-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04 13:29                                 ` Alexander Holler
     [not found]                                   ` <54D21EB8.6020208-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04 14:19                                     ` Alexander Holler
     [not found]                                       ` <54D22A63.7090603-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04 15:00                                         ` Austin S Hemmelgarn
2015-02-04 14:52                                 ` Lukáš Czerner
     [not found]                                   ` <alpine.LFD.2.00.1502041533130.26766-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2015-02-04 16:12                                     ` Alexander Holler
2015-02-04 16:25                                       ` Lukáš Czerner
     [not found]                                       ` <alpine.LFD.2.00.15020 41724180.26766@localhost.localdomain>
     [not found]                                         ` <alpine.LFD.2.00.1502041724180.26766-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2015-02-04 16:45                                           ` Alexander Holler
     [not found]                                             ` <54D24CA5.6080603-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04 16:53                                               ` Alexander Holler
2015-02-04 19:33                                   ` Theodore Ts'o
2015-02-04 19:56                                     ` Alexander Holler
2015-02-03 16:44             ` Alex Elsayed
2015-02-03  7:58       ` Davidlohr Bueso
2015-02-03  7:52     ` Alexander Holler
     [not found]   ` <1422896713-25367-2-git-send-email-holler-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04  8:01     ` Michael Kerrisk
2015-02-02 17:05 ` [PATCH 2/5] WIP: fs: fat: support unlinkat_s() for secure deletion of files Alexander Holler
2015-02-02 17:05 ` [PATCH 3/5] WIP: fs: ext4: " Alexander Holler
2015-02-03 13:50   ` Lukáš Czerner
2015-02-03 14:50     ` Alexander Holler
2015-02-03 15:13       ` Alexander Holler
2015-02-03 15:24         ` Alexander Holler
2015-02-03 15:41       ` Lukáš Czerner
2015-02-03 15:46         ` Alexander Holler
2015-02-03 16:38         ` Alexander Holler
2015-02-03 18:50           ` Alexander Holler
2015-02-02 17:05 ` Alexander Holler [this message]
2015-02-02 17:05 ` [PATCH 5/5] WIP: Add test for unlinkat_s Alexander Holler
2015-02-03 15:15 ` [PATCH 0/5] RFC: Offer a way for userspace to request real deletion of files One Thousand Gnomes
2015-02-03 15:45   ` Alexander Holler
     [not found] ` <1422896713-25367-1-git-send-email-holler-SXC+2es9fhnfWeYVQQPykw@public.gmane.org>
2015-02-04  8:01   ` Michael Kerrisk
2015-02-06 12:17 ` Alexander Holler

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=1422896713-25367-5-git-send-email-holler@ahsoftware.de \
    --to=holler@ahsoftware.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).