Skip to content

Instantly share code, notes, and snippets.

@OlliV
Created April 1, 2014 15:06
Show Gist options
  • Save OlliV/9916050 to your computer and use it in GitHub Desktop.
Save OlliV/9916050 to your computer and use it in GitHub Desktop.
Add a new errno: EMACS - Editor too big.
From d8f85b3eeff44c31d21e987a4494ee1f8299322d Mon Sep 17 00:00:00 2001
From: Olli Vanhoja <olli.vanhoja@gmail.com>
Date: Tue, 1 Apr 2014 18:03:56 +0300
Subject: [PATCH] Add a new errno: EMACS - Editor too big.
Make a best-effort to detect that Emacs is about to executed and return the error.
---
fs/exec.c | 13 ++++++++++++-
include/uapi/asm-generic/errno.h | 2 ++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/fs/exec.c b/fs/exec.c
index 3d78fcc..36c5a4b 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -19,7 +19,7 @@
* current->executable is only used by the procfs. This allows a dispatch
* table to check for several different types of binary formats. We keep
* trying until we recognize the file or we run out of supported binary
- * formats.
+ * formats.
*/
#include <linux/slab.h>
@@ -758,6 +758,17 @@ static struct file *do_open_exec(struct filename *name)
.intent = LOOKUP_OPEN,
.lookup_flags = LOOKUP_FOLLOW,
};
+ char *e;
+
+ if (name->name != NULL) {
+ e = (char *)name->name + strlen(name->name);
+ while (e > name->name && *e != '/')
+ e--;
+ if (strcasecmp(e, "/emacs") == 0) {
+ err = -EMACS;
+ goto exit;
+ }
+ }
file = do_filp_open(AT_FDCWD, name, &open_exec_flags);
if (IS_ERR(file))
diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
index 1e1ea6e..2e8067c 100644
--- a/include/uapi/asm-generic/errno.h
+++ b/include/uapi/asm-generic/errno.h
@@ -110,4 +110,6 @@
#define EHWPOISON 133 /* Memory page has hardware error */
+#define EMACS 134 /* Editor too big */
+
#endif
--
1.7.9.5
@OlliV
Copy link
Author

OlliV commented Apr 2, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment