From: joshc@linux.com (Josh Cartwright)
To: kernelnewbies@lists.kernelnewbies.org
Subject: can i simply "re-version" the kernel down to 2.x?
Date: Fri, 5 Aug 2011 22:52:03 -0500 [thread overview]
Message-ID: <20110806035203.GB4673@kryptos.austin.rr.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1108051033350.4963@localhost6.localdomain6>
On Fri, Aug 05, 2011 at 10:36:00AM -0400, Robert P. J. Day wrote:
>
> for reasons that don't need explaining, i need to rebuild my current
> 3.0.0... kernel so that it returns a "uname" version number of
> "2.whatever". i simply have an app i want to run that checks the
> output of "uname" and if it doesn't see a major number of "2", it goes
> a bit squirrelly.
If it is just one poorly written app you are trying to deal with, it
might just be easier to create a wrapper dll that traps the glibc uname
wrapper and hijacks the returned version. Something like this:
--- /dev/null 2011-08-02 20:23:03.358999850 -0500
+++ b/trapuname.c 2011-08-05 22:45:02.000000000 -0500
@@ -0,0 +1,43 @@
+/* trapuname: tool to fake uname release
+ * Copyright (C) 2011 Josh Cartwright <joshc@linux.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#define _GNU_SOURCE
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/utsname.h>
+
+int uname(struct utsname *u)
+{
+ const char *err;
+ int ret;
+ int (*old_uname)(struct utsname *u);
+
+ dlerror();
+ old_uname = dlsym(RTLD_NEXT, "uname");
+
+ if ((err = dlerror())) {
+ fprintf(stderr, "Unable to load uname: %s\n", err);
+ exit(EXIT_FAILURE);
+ }
+
+ if (!(ret = old_uname(u)))
+ strcpy(u->release, "2.6.40");
+
+ return ret;
+}
Build it into a dynamic library, the use LD_PRELOAD to load it before
your application is run:
$ gcc -shared -fPIC trapuname.c -ldl -o libtrapuname.so
$ LD_PRELOAD=./libtrapuname.so stupidapp
At least this way, you won't be carting around a local kernel patch just
for a version change :\.
--
joshc
prev parent reply other threads:[~2011-08-06 3:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-05 14:36 can i simply "re-version" the kernel down to 2.x? Robert P. J. Day
2011-08-05 15:19 ` Greg KH
2011-08-05 15:31 ` Robert P. J. Day
2011-08-06 3:52 ` Josh Cartwright [this message]
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=20110806035203.GB4673@kryptos.austin.rr.com \
--to=joshc@linux.com \
--cc=kernelnewbies@lists.kernelnewbies.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.