commit 3bb0f0fbdde37789ee51e718225cbd278e9167f9
Author: sin <[email protected]>
Date: Sat Feb 15 18:26:01 2014 +0000
Check setmntent() for failures
diff --git a/swapoff.c b/swapoff.c
index 806d1f0..2d2b7ac 100644
--- a/swapoff.c
+++ b/swapoff.c
@@ -36,6 +36,8 @@ main(int argc, char *argv[])
FILE *fp;
fp = setmntent("/etc/fstab", "r");
+ if (!fp)
+ eprintf("setmntent %s:", "/etc/fstab");
while ((me = getmntent(fp)) != NULL) {
if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0) {
if (swapoff(me->mnt_fsname) < 0) {
diff --git a/swapon.c b/swapon.c
index 40e6c9f..6b3d32f 100644
--- a/swapon.c
+++ b/swapon.c
@@ -43,6 +43,8 @@ main(int argc, char *argv[])
FILE *fp;
fp = setmntent("/etc/fstab", "r");
+ if (!fp)
+ eprintf("setmntent %s:", "/etc/fstab");
while ((me = getmntent(fp)) != NULL) {
if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0
&& (hasmntopt(me, MNTOPT_NOAUTO) == NULL)) {