diff options
author | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2012-06-15 20:13:31 -0300 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2012-06-15 21:31:05 -0300 |
commit | a4fb97a71e336394e1a497c2b75ea42907937d1e (patch) | |
tree | 021aa685959382eca21e510c346bc92aeed8366d | |
parent | 015946da0ce8b25b854644bbc61dfa22cfcf912e (diff) | |
download | kmod-a4fb97a71e336394e1a497c2b75ea42907937d1e.tar.gz |
depmod: return error when index is truncated due to ENOSPC
Before:
=======
[lucas@vader kmod]$ sudo depmod
[lucas@vader kmod]$ echo $?
0
[lucas@vader kmod]$ ls -l /lib/modules/$(uname -r)
total 12
drwxr-xr-x 8 root root 160 Jun 13 11:05 kernel
-rw-r--r-- 1 root root 12288 Jun 15 21:29 modules.alias
-rw-r--r-- 1 root root 0 Jun 15 21:29 modules.alias.bin
-rw-r--r-- 1 root root 0 Jun 15 21:29 modules.dep
-rw-r--r-- 1 root root 0 Jun 15 21:29 modules.dep.bin
-rw-r--r-- 1 root root 0 Jun 15 21:29 modules.devname
-rw-r--r-- 1 root root 0 Jun 15 21:29 modules.softdep
-rw-r--r-- 1 root root 0 Jun 15 21:29 modules.symbols
-rw-r--r-- 1 root root 0 Jun 15 21:29 modules.symbols.bin
Note that modules.alias is truncated and the other have size == 0
After:
======
[lucas@vader kmod]$ sudo ./tools/depmod
WARNING: could not open /lib/modules/3.5.0-rc2-demarchi-00028-g94fa83c/modules.order: No such file or directory
ERROR: Could not create index: output truncated: No space left on device
[lucas@vader kmod]$ echo $?
1
-rw-r--r-- | tools/depmod.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/depmod.c b/tools/depmod.c index fc23d29..790cc76 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -2237,6 +2237,7 @@ static int depmod_output(struct depmod *depmod, FILE *out) FILE *fp = out; char tmp[NAME_MAX] = ""; int r; + long eof; if (fp == NULL) { int flags = O_CREAT | O_TRUNC | O_WRONLY; @@ -2262,6 +2263,7 @@ static int depmod_output(struct depmod *depmod, FILE *out) if (fp == out) continue; + eof = ftell(fp); fclose(fp); if (r < 0) { if (unlinkat(dfd, tmp, 0) != 0) @@ -2280,6 +2282,13 @@ static int depmod_output(struct depmod *depmod, FILE *out) dname, tmp, dname, itr->name); break; } + + if (eof == EOF) { + err = -ENOSPC; + ERR("Could not create index: output truncated: %s\n", + strerror(-err)); + break; + } } if (dfd >= 0) |