sbin_PROGRAMS = losetup swapon
dist_man_MANS = fstab.5 mount.8 swapoff.8 swapon.8 umount.8 losetup.8
-# generic sources for all programs (mount, umount, swapon, losetup)
-srcs_common = sundries.c xmalloc.c ../lib/canonicalize.c
+# generic sources for all programs (mount, umount, losetup)
+srcs_common = sundries.c xmalloc.c ../lib/canonicalize.c sundries.h xmalloc.h
# generic header for mount and umount
hdrs_mount = fstab.h mount_mntent.h mount_constants.h \
- lomount.h xmalloc.h getusername.h loop.h sundries.h
+ lomount.h getusername.h loop.h
# generic sources for mount and umount
srcs_mount = fstab.c mount_mntent.c getusername.c lomount.c devname.c devname.h \
umount_LDFLAGS = $(SUID_LDFLAGS) $(AM_LDFLAGS)
umount_LDADD = $(ldadd_common)
-swapon_SOURCES = swapon.c swap_constants.h $(srcs_common) devname.c devname.h \
- ../lib/linux_version.c ../lib/blkdev.c ../lib/fsprobe.c
+swapon_SOURCES = swapon.c swap_constants.h ../lib/linux_version.c \
+ ../lib/blkdev.c ../lib/fsprobe.c ../lib/canonicalize.c
swapon_CFLAGS = $(cflags_common)
swapon_LDADD = $(ldadd_common)
-losetup_SOURCES = lomount.c $(srcs_common) loop.h lomount.h xmalloc.h sundries.h
+losetup_SOURCES = lomount.c $(srcs_common) loop.h lomount.h
losetup_CPPFLAGS = -DMAIN $(AM_CPPFLAGS)
mount_static_LDADD =
/*
* A swapon(8)/swapoff(8) for Linux 0.99.
*/
-#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <getopt.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <stdint.h>
+
#include "bitops.h"
#include "blkdev.h"
-#include "xmalloc.h"
#include "swap_constants.h"
#include "nls.h"
#include "fsprobe.h"
-#include "devname.h"
#include "pathnames.h"
-#include "sundries.h"
#include "swapheader.h"
#define PATH_MKSWAP "/sbin/mkswap"
SIG_SWSUSPEND
};
-int all = 0;
+int all;
int priority = -1; /* non-prioritized swap by default */
/* If true, don't complain if the device/file doesn't exist */
-int ifexists = 0;
+int ifexists;
+
+int verbose;
+char *progname;
static struct option longswaponopts[] = {
/* swapon only */
printf(_("%s on %s\n"), progname, orig_special);
if (!canonic) {
- special = spec_to_devname(orig_special);
+ special = fsprobe_get_devname_by_spec(orig_special);
if (!special)
return cannot_find(orig_special);
}
printf(_("%s on %s\n"), progname, orig_special);
if (!canonic) {
- special = spec_to_devname(orig_special);
+ special = fsprobe_get_devname_by_spec(orig_special);
if (!special)
return cannot_find(orig_special);
}
if (skip)
continue;
- special = spec_to_devname(fstab->mnt_fsname);
+ special = fsprobe_get_devname_by_spec(fstab->mnt_fsname);
if (!special) {
if (!ifexists)
status |= cannot_find(fstab->mnt_fsname);
static int ulct = 0;
static void addl(const char *label) {
- llist = (const char **) xrealloc(llist, (++llct) * sizeof(char *));
+ llist = (const char **) realloc(llist, (++llct) * sizeof(char *));
+ if (!llist)
+ exit(EXIT_FAILURE);
llist[llct-1] = label;
}
static void addu(const char *uuid) {
- ulist = (const char **) xrealloc(ulist, (++ulct) * sizeof(char *));
+ ulist = (const char **) realloc(ulist, (++ulct) * sizeof(char *));
+ if (!ulist)
+ exit(EXIT_FAILURE);
ulist[ulct-1] = uuid;
}
if (!streq(fstab->mnt_type, MNTTYPE_SWAP))
continue;
- special = spec_to_devname(fstab->mnt_fsname);
+ special = fsprobe_get_devname_by_spec(fstab->mnt_fsname);
if (!special)
continue;