Check setmntent() for failures
This commit is contained in:
parent
005e90a7ff
commit
3bb0f0fbdd
@ -36,6 +36,8 @@ main(int argc, char *argv[])
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
fp = setmntent("/etc/fstab", "r");
|
fp = setmntent("/etc/fstab", "r");
|
||||||
|
if (!fp)
|
||||||
|
eprintf("setmntent %s:", "/etc/fstab");
|
||||||
while ((me = getmntent(fp)) != NULL) {
|
while ((me = getmntent(fp)) != NULL) {
|
||||||
if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0) {
|
if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0) {
|
||||||
if (swapoff(me->mnt_fsname) < 0) {
|
if (swapoff(me->mnt_fsname) < 0) {
|
||||||
|
2
swapon.c
2
swapon.c
@ -43,6 +43,8 @@ main(int argc, char *argv[])
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
fp = setmntent("/etc/fstab", "r");
|
fp = setmntent("/etc/fstab", "r");
|
||||||
|
if (!fp)
|
||||||
|
eprintf("setmntent %s:", "/etc/fstab");
|
||||||
while ((me = getmntent(fp)) != NULL) {
|
while ((me = getmntent(fp)) != NULL) {
|
||||||
if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0
|
if (strcmp(me->mnt_type, MNTTYPE_SWAP) == 0
|
||||||
&& (hasmntopt(me, MNTOPT_NOAUTO) == NULL)) {
|
&& (hasmntopt(me, MNTOPT_NOAUTO) == NULL)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user