summaryrefslogtreecommitdiff
path: root/quotasys.c
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2002-03-27 16:40:27 +0000
committerjkar8572 <jkar8572>2002-03-27 16:40:27 +0000
commitadb5b187b252912f1853722477b04db8b5f0aaed (patch)
tree1f2422b1e9d90e70a5b5c6efbe950082e84854be /quotasys.c
parent5975341695e27f23f5a58758954d1ea31c2d0d25 (diff)
Fixed bug in quota format detection - avoid SIGSEGV on old kernels. (Jan Kara)
Diffstat (limited to 'quotasys.c')
-rw-r--r--quotasys.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/quotasys.c b/quotasys.c
index 8b1feec..77d8c83 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -15,6 +15,7 @@
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
+#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/vfs.h>
@@ -542,9 +543,18 @@ void init_kernel_interface(void)
}
else {
struct v2_dqstats v2_stats;
+ struct sigaction sig, oldsig;
if (!stat("/proc/fs/xfs/stat", &st))
kernel_formats |= (1 << QF_XFS);
+ /* This signal handling is needed because old kernels send us SIGSEGV as they try to resolve the device */
+ sig.sa_handler = SIG_IGN;
+ sig.sa_sigaction = NULL;
+ if (sigemptyset(&sig.sa_mask) < 0)
+ die(2, _("Can't create set for sigaction(): %s\n"), strerror(errno));
+ sig.sa_flags = 0;
+ if (sigaction(SIGSEGV, &sig, &oldsig) < 0)
+ die(2, _("Can't set signal handler: %s\n"), strerror(errno));
if (quotactl(QCMD(Q_V2_GETSTATS, 0), NULL, 0, (void *)&v2_stats) >= 0) {
version = v2_stats.version;
kernel_formats |= (1 << QF_VFSV0);
@@ -578,6 +588,8 @@ void init_kernel_interface(void)
version = 6*10000+4*100+0;
}
}
+ if (sigaction(SIGSEGV, &oldsig, NULL) < 0)
+ die(2, _("Can't reset signal handler: %s\n"), strerror(errno));
}
if (version > KERN_KNOWN_QUOTA_VERSION)