swapon/off: revert the non-portable change made in 2014: use setmntent, not fopen
function old new delta swap_on_off_main 449 474 +25 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
1 parent
daf8ec40e0
commit
87e54246b6
1 file changed
+5
-2
@@ -233,7 +233,10 @@ static int do_em_all_in_fstab(void)
|
||||
{
|
||||
struct mntent *m;
|
||||
int err = 0;
|
||||
FILE *f = xfopen_for_read("/etc/fstab"); /* poor man's setmntent */
|
||||
FILE *f = setmntent("/etc/fstab", "r");
|
||||
|
||||
if (!f)
|
||||
bb_simple_perror_msg_and_die("/etc/fstab");
|
||||
|
||||
while ((m = getmntent(f)) != NULL) {
|
||||
if (strcmp(m->mnt_type, MNTTYPE_SWAP) == 0) {
|
||||
@@ -265,7 +268,7 @@ static int do_em_all_in_fstab(void)
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
fclose(f);
|
||||
endmntent(f);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user