Check setmntent() for failures

This commit is contained in:
sin 2014-02-15 18:26:01 +00:00
parent 005e90a7ff
commit 3bb0f0fbdd
2 changed files with 4 additions and 0 deletions

View File

@ -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) {

View File

@ -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)) {