Re: Assertion fails in init_module.c on 32bits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 20 Jun 2012 09:15:33 -0300
Lucas De Marchi <lucas.demarchi@xxxxxxxxxxxxxx> wrote:

> On Wed, Jun 20, 2012 at 8:56 AM, Robert Milasan <rmilasan@xxxxxxx>
> wrote:
> > On Wed, 20 Jun 2012 08:34:59 -0300
> > Lucas De Marchi <lucas.demarchi@xxxxxxxxxxxxxx> wrote:
> >
> >> Hi Robert,
> >>
> >> please CC linux-modules@xxxxxxxxxxxxxxx so others can benefit from
> >> the responses. I'm doing so now.
> >>
> >> On Wed, Jun 20, 2012 at 8:21 AM, Robert Milasan <rmilasan@xxxxxxx>
> >> wrote:
> >> > Hello, I'm trying now to build kmod 9 on 64 and 32 bits
> >> > opensuse. On 64bits everything is fine, but on 32bits it fails
> >> > in init_modules.c: 150:assert(mkdir_p(buf, 0755) >= 0);
> >> >
> >> > If I drop assert, all works. Do you have an idea why it fails?
> >>
> >> Does "make check" work for you after removing this assert? Some of
> >> the tests that rely on being able to create dirs on testsuite's
> >> rootfs should fail if you didn't create the dirs.
> >>
> >> On your 32 bits machine, is your testsuite/rootfs dir (or any of
> >> the dirs below)  read-only?
> >>
> >> Lucas De Marchi
> >
> > If I drop assert(mkdir_p...) then all works. rootfs and the below
> > dirs all have the rights "0755" so all good, but this issue doesn't
> > happen on 64bits which is a bit strange for me. Maybe there is
> > something wrong in mkdir.c -> mkdir_p function.
> 
> Maybe... gotta check this on a 32 bits machine.
> 
> >
> > Anyway I've asked around and some people said that using assert on
> > "mkdir_p" is kind of a bad idea, but I'm not a developer so I
> > wouldn't know.
> 
> Yeah, except that this code path runs only on *testsuite*, i.e.  it's
> part of the tests we make to check it's right, but it's not part of
> libkmod, modprobe or depmod, etc that runs on production.
> 
> I put the assert because there are tests that depend on being able to
> create dirs: among others, the "install command loop" test. If dir is
> not created, it will fail nonetheless, but instead of saying it's
> because of a failed dir creation it will create a fork bomb (yeah,
> it's a loop of fork + exec). I preferred failing the test earlier than
> having to killall modprobe later or wait for kernel's oom killer.
> 
> 
> Lucas De Marchi

OK, now I know why it fails errno -17 which means the dir already
exists.

test-init: testsuite/init_module.c:155: create_sysfs_files: Assertion
`err >= 0' failed. err: -17

This is a small patch for that:

Index: kmod-9/testsuite/init_module.c
===================================================================
--- kmod-9.orig/testsuite/init_module.c
+++ kmod-9/testsuite/init_module.c
@@ -142,12 +142,17 @@ static int create_sysfs_files(const char
 	char buf[PATH_MAX];
 	const char *sysfsmod = "/sys/module/";
 	int len = strlen(sysfsmod);
+	int err = 0;
 
 	memcpy(buf, sysfsmod, len);
 	strcpy(buf + len, modname);
 	len += strlen(modname);
 
-	assert(mkdir_p(buf, 0755) >= 0);
+	// this fails on 32bit systems, we can't use assert
+	// assert(mkdir_p(buf, 0755) >= 0);
+	err = mkdir_p(buf, 0755);
+	printf("err: %d\n", err);
+	assert(err >= 0);
 
 	strcpy(buf + len, "/initstate");
 	return write_one_line_file(buf, "live\n", strlen("live\n"));

So maybe fixing mkdir_p would be a better idea or something, don't know
yet.

-- 
Robert Milasan
L3 Support Engineer
SUSE
rmilasan@xxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux