linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jani Monoses <jani@virtualro.ic.ro>
To: linux-kernel@vger.kernel.org
Subject: [patch] get_binfmt/put_binfmt macros
Date: Wed, 20 Dec 2000 01:09:52 +0200 (EET)	[thread overview]
Message-ID: <Pine.LNX.4.10.10012200102430.18898-100000@virtualro.ic.ro> (raw)


Hi

	this patch replaces the binfmt module handling parts with macro
calls which do the same thing similar do the get/put_exec_domain macros.
Also changes an internal function name in fs/exec.c (put_binfmt) which
does almost the same thing as put_binfmt (one check less) to avoid
compilation conflicts.
Files affected: fork.c, exit.c, fs/exec.c ,include/linux/binfmts.h

It is against test12 but test13pre3 does not affect these files.

Comments are welcome.

Jani.	


diff -uNr -X dontdiff /usr/src/clean/linux/fs/exec.c linux/fs/exec.c
--- /usr/src/clean/linux/fs/exec.c	Tue Dec 12 11:25:55 2000
+++ linux/fs/exec.c	Wed Dec 20 00:13:55 2000
@@ -87,7 +87,7 @@
 	return -EINVAL;
 }
 
-static inline void put_binfmt(struct linux_binfmt * fmt)
+static inline void _put_binfmt(struct linux_binfmt * fmt)
 {
 	if (fmt->module)
 		__MOD_DEC_USE_COUNT(fmt->module);
@@ -135,7 +135,7 @@
 			read_unlock(&binfmt_lock);
 			error = fmt->load_shlib(file);
 			read_lock(&binfmt_lock);
-			put_binfmt(fmt);
+			_put_binfmt(fmt);
 			if (error != -ENOEXEC)
 				break;
 		}
@@ -810,7 +810,7 @@
 			read_unlock(&binfmt_lock);
 			retval = fn(bprm, regs);
 			if (retval >= 0) {
-				put_binfmt(fmt);
+				_put_binfmt(fmt);
 				allow_write_access(bprm->file);
 				if (bprm->file)
 					fput(bprm->file);
@@ -819,7 +819,7 @@
 				return retval;
 			}
 			read_lock(&binfmt_lock);
-			put_binfmt(fmt);
+			_put_binfmt(fmt);
 			if (retval != -ENOEXEC)
 				break;
 			if (!bprm->file) {
@@ -924,11 +924,11 @@
 void set_binfmt(struct linux_binfmt *new)
 {
 	struct linux_binfmt *old = current->binfmt;
-	if (new && new->module)
-		__MOD_INC_USE_COUNT(new->module);
+
+	get_binfmt(new);
 	current->binfmt = new;
-	if (old && old->module)
-		__MOD_DEC_USE_COUNT(old->module);
+	put_binfmt(old);
+
 }
 
 int do_coredump(long signr, struct pt_regs * regs)
diff -uNr -X dontdiff /usr/src/clean/linux/include/linux/binfmts.h linux/include/linux/binfmts.h
--- /usr/src/clean/linux/include/linux/binfmts.h	Tue Dec 12 11:42:22 2000
+++ linux/include/linux/binfmts.h	Wed Dec 20 00:10:59 2000
@@ -59,6 +59,12 @@
 extern int do_coredump(long signr, struct pt_regs * regs);
 extern void set_binfmt(struct linux_binfmt *new);
 
+#define get_binfmt(bf)	\
+	if (bf && bf->module) __MOD_INC_USE_COUNT(bf->module)
+
+#define put_binfmt(bf)	\
+	if (bf && bf->module) __MOD_DEC_USE_COUNT(bf->module)
+	
 
 #if 0
 /* this went away now */
diff -uNr -X dontdiff /usr/src/clean/linux/kernel/exit.c linux/kernel/exit.c
--- /usr/src/clean/linux/kernel/exit.c	Tue Dec 12 11:25:58 2000
+++ linux/kernel/exit.c	Wed Dec 20 00:11:40 2000
@@ -448,8 +448,7 @@
 	tsk->exit_code = code;
 	exit_notify();
 	put_exec_domain(tsk->exec_domain);
-	if (tsk->binfmt && tsk->binfmt->module)
-		__MOD_DEC_USE_COUNT(tsk->binfmt->module);
+	put_binfmt(tsk->binfmt);
 	schedule();
 /*
  * In order to get rid of the "volatile function does return" message
diff -uNr -X dontdiff /usr/src/clean/linux/kernel/fork.c linux/kernel/fork.c
--- /usr/src/clean/linux/kernel/fork.c	Tue Dec 12 11:25:58 2000
+++ linux/kernel/fork.c	Wed Dec 20 00:10:44 2000
@@ -578,8 +578,7 @@
 	
 	get_exec_domain(p->exec_domain);
 
-	if (p->binfmt && p->binfmt->module)
-		__MOD_INC_USE_COUNT(p->binfmt->module);
+	get_binfmt(p->binfmt);
 
 	p->did_exec = 0;
 	p->swappable = 0;
@@ -701,8 +700,8 @@
 	exit_files(p); /* blocking */
 bad_fork_cleanup:
 	put_exec_domain(p->exec_domain);
-	if (p->binfmt && p->binfmt->module)
-		__MOD_DEC_USE_COUNT(p->binfmt->module);
+	put_binfmt(p->binfmt);
+	
 bad_fork_cleanup_count:
 	atomic_dec(&p->user->processes);
 	free_uid(p->user);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

                 reply	other threads:[~2000-12-19 23:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=Pine.LNX.4.10.10012200102430.18898-100000@virtualro.ic.ro \
    --to=jani@virtualro.ic.ro \
    --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).