Imported from util-linux-2.12o tarball.
This commit is contained in:
parent
a47f2e6614
commit
756bfd018e
8
HISTORY
8
HISTORY
|
@ -1,3 +1,11 @@
|
||||||
|
util-linux 2.12n,o
|
||||||
|
|
||||||
|
* lomount: revert patch from 2.12j
|
||||||
|
* lptune.8: -T option is obsolete
|
||||||
|
* mkswap, mkswap.8, swapon: support labels
|
||||||
|
(use HAVE_BLKID=no as long as the blkid library doesnt support this)
|
||||||
|
* umount: allow user unmounting repeatedly mounted nfs mounts
|
||||||
|
|
||||||
util-linux 2.12m
|
util-linux 2.12m
|
||||||
|
|
||||||
* cfdisk: recognize JFS, support reiserfs labels (flavio.stanchina@tin.it)
|
* cfdisk: recognize JFS, support reiserfs labels (flavio.stanchina@tin.it)
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -52,7 +52,15 @@ distclean: make_include clean
|
||||||
cd mount && make distclean
|
cd mount && make distclean
|
||||||
-rm -f defines.h make_include
|
-rm -f defines.h make_include
|
||||||
|
|
||||||
#
|
tar: make_include clean
|
||||||
|
cd mount && make distclean
|
||||||
|
cd po && make update-po && make util-linux.pot && \
|
||||||
|
mv util-linux.pot ../../util-linux-$(VERSION).pot && \
|
||||||
|
make distclean
|
||||||
|
-rm -f defines.h make_include
|
||||||
|
cd .. && tar cvfz util-linux-$(VERSION).tar.gz ./util-linux-$(VERSION)
|
||||||
|
@echo = made util-linux-$(VERSION).pot and util-linux-$(VERSION).tar.gz
|
||||||
|
|
||||||
# dist:
|
# dist:
|
||||||
# (cd /tmp; \
|
# (cd /tmp; \
|
||||||
# rm -rf /tmp/util-linux-$(VERSION); \
|
# rm -rf /tmp/util-linux-$(VERSION); \
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
# H4. For nls.h: do we have <locale.h>?
|
# H4. For nls.h: do we have <locale.h>?
|
||||||
# H5. For cal.c: do we have <langinfo.h>?
|
# H5. For cal.c: do we have <langinfo.h>?
|
||||||
# H6. For mkswap.c: do we have <sys/user.h> or <asm/page.h>?
|
# H6. For mkswap.c: do we have <sys/user.h> or <asm/page.h>?
|
||||||
|
# H6a For mkswap.c: do we have <uuid/uuid.h>?
|
||||||
# H7. For nfsmount.c: do we have <rpcsvc/nfs_prot.h>?
|
# H7. For nfsmount.c: do we have <rpcsvc/nfs_prot.h>?
|
||||||
# H8. For nfsmount.h (nfsmount_xdr.c: int32_t): do we have <asm/types.h>?
|
# H8. For nfsmount.h (nfsmount_xdr.c: int32_t): do we have <asm/types.h>?
|
||||||
# H9. For raw.c: do we have <linux/raw.h>?
|
# H9. For raw.c: do we have <linux/raw.h>?
|
||||||
|
@ -163,6 +164,16 @@ else if ./testincl "asm/page.h"; then
|
||||||
echo "#define HAVE_asm_page_h" >> defines.h
|
echo "#define HAVE_asm_page_h" >> defines.h
|
||||||
fi; fi
|
fi; fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# H6a. For mkswap.c: do we have <uuid/uuid.h>?
|
||||||
|
#
|
||||||
|
if ./testincl "uuid/uuid.h"; then
|
||||||
|
echo "#define HAVE_uuid_uuid_h" >> defines.h
|
||||||
|
echo "HAVE_UUID=yes" >> make_include
|
||||||
|
else
|
||||||
|
echo "HAVE_UUID=no" >> make_include
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# H7. For nfsmount.c: do we have <rpcsvc/nfs_prot.h>?
|
# H7. For nfsmount.c: do we have <rpcsvc/nfs_prot.h>?
|
||||||
#
|
#
|
||||||
|
|
|
@ -36,6 +36,10 @@ ifeq "$(HAVE_ZLIB)" "yes"
|
||||||
SBIN:=$(SBIN) fsck.cramfs mkfs.cramfs
|
SBIN:=$(SBIN) fsck.cramfs mkfs.cramfs
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq "$(HAVE_UUID)" "yes"
|
||||||
|
MKSWAP_LIBS=-luuid
|
||||||
|
endif
|
||||||
|
|
||||||
all: $(SBIN) $(USRBIN)
|
all: $(SBIN) $(USRBIN)
|
||||||
|
|
||||||
fsck.cramfs: fsck.cramfs.o
|
fsck.cramfs: fsck.cramfs.o
|
||||||
|
@ -50,6 +54,9 @@ fsck.cramfs.o mkfs.cramfs.o: cramfs.h
|
||||||
|
|
||||||
fsck.minix.o mkfs.minix.o: bitops.h minix.h
|
fsck.minix.o mkfs.minix.o: bitops.h minix.h
|
||||||
|
|
||||||
|
mkswap: mkswap.o $(LIB)/xstrncpy.o
|
||||||
|
$(CC) $(LDFLAGS) -o $@ $^ $(MKSWAP_LIBS)
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
$(INSTALLDIR) $(SBINDIR) $(USRBINDIR) $(ETCDIR)
|
$(INSTALLDIR) $(SBINDIR) $(USRBINDIR) $(ETCDIR)
|
||||||
$(INSTALLBIN) $(SBIN) $(SBINDIR)
|
$(INSTALLBIN) $(SBIN) $(SBINDIR)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
.SH NAME
|
.SH NAME
|
||||||
mkswap \- set up a Linux swap area
|
mkswap \- set up a Linux swap area
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.BI "mkswap [\-c] [\-v" N "] [\-f] [\-p " PSZ "] "device " [" size "]"
|
.BI "mkswap [\-c] [\-v" N "] [\-f] [\-p " PSZ "] [\-L " label "] " device " [" size "]"
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B mkswap
|
.B mkswap
|
||||||
sets up a Linux swap area on a device or in a file.
|
sets up a Linux swap area on a device or in a file.
|
||||||
|
@ -131,6 +131,10 @@ as that probably means one is going to erase the partition table.
|
||||||
.BI "\-p " PSZ
|
.BI "\-p " PSZ
|
||||||
Specify the page size to use.
|
Specify the page size to use.
|
||||||
.TP
|
.TP
|
||||||
|
.BI "\-L " label
|
||||||
|
Specify a label, to allow swapon by label.
|
||||||
|
(Only for new style swap areas.)
|
||||||
|
.TP
|
||||||
.B \-v0
|
.B \-v0
|
||||||
Create an old style swap area.
|
Create an old style swap area.
|
||||||
.TP
|
.TP
|
||||||
|
|
|
@ -39,8 +39,15 @@
|
||||||
#include <sys/ioctl.h> /* for _IO */
|
#include <sys/ioctl.h> /* for _IO */
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include "../defines.h"
|
||||||
|
#include "swapheader.h"
|
||||||
|
#include "xstrncpy.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_uuid_uuid_h
|
||||||
|
#include <uuid/uuid.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Try to get PAGE_SIZE from libc or kernel includes */
|
/* Try to get PAGE_SIZE from libc or kernel includes */
|
||||||
#ifdef HAVE_sys_user_h
|
#ifdef HAVE_sys_user_h
|
||||||
/* Note: <sys/user.h> says: for gdb only */
|
/* Note: <sys/user.h> says: for gdb only */
|
||||||
|
@ -154,18 +161,11 @@ static int kernel_pagesize; /* obtained via getpagesize(); */
|
||||||
static int defined_pagesize = 0; /* PAGE_SIZE, when that exists */
|
static int defined_pagesize = 0; /* PAGE_SIZE, when that exists */
|
||||||
static int pagesize;
|
static int pagesize;
|
||||||
static long *signature_page;
|
static long *signature_page;
|
||||||
|
struct swap_header_v1 *p;
|
||||||
struct swap_header_v1 {
|
|
||||||
char bootbits[1024]; /* Space for disklabel etc. */
|
|
||||||
unsigned int version;
|
|
||||||
unsigned int last_page;
|
|
||||||
unsigned int nr_badpages;
|
|
||||||
unsigned int padding[125];
|
|
||||||
unsigned int badpages[1];
|
|
||||||
} *p;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_signature_page(void) {
|
init_signature_page(void) {
|
||||||
|
|
||||||
#ifdef PAGE_SIZE
|
#ifdef PAGE_SIZE
|
||||||
defined_pagesize = PAGE_SIZE;
|
defined_pagesize = PAGE_SIZE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -192,7 +192,7 @@ init_signature_page(void) {
|
||||||
pagesize, defined_pagesize);
|
pagesize, defined_pagesize);
|
||||||
|
|
||||||
signature_page = (long *) malloc(pagesize);
|
signature_page = (long *) malloc(pagesize);
|
||||||
memset(signature_page,0,pagesize);
|
memset(signature_page, 0, pagesize);
|
||||||
p = (struct swap_header_v1 *) signature_page;
|
p = (struct swap_header_v1 *) signature_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +203,62 @@ write_signature(char *sig) {
|
||||||
strncpy(sp+pagesize-10, sig, 10);
|
strncpy(sp+pagesize-10, sig, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static int
|
||||||
|
tohex(int a) {
|
||||||
|
return ((a < 10) ? '0'+a : 'a'+a-10);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
uuid_unparse(unsigned char *uuid, char *s) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i<16; i++) {
|
||||||
|
if (i == 4 || i == 6 || i == 8 || i == 10)
|
||||||
|
*s++ = '-';
|
||||||
|
*s++ = tohex((uuid[i] >> 4) & 0xf);
|
||||||
|
*s++ = tohex(uuid[i] & 0xf);
|
||||||
|
}
|
||||||
|
*s = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
write_uuid_and_label(char *uuid, char *volume_name) {
|
||||||
|
struct swap_header_v1_2 *h;
|
||||||
|
|
||||||
|
/* Sanity check */
|
||||||
|
if (sizeof(struct swap_header_v1) !=
|
||||||
|
sizeof(struct swap_header_v1_2)) {
|
||||||
|
fprintf(stderr,
|
||||||
|
_("Bad swap header size, no label written.\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
h = (struct swap_header_v1_2 *) signature_page;
|
||||||
|
if (uuid)
|
||||||
|
memcpy(h->uuid, uuid, sizeof(h->uuid));
|
||||||
|
if (volume_name) {
|
||||||
|
xstrncpy(h->volume_name, volume_name, sizeof(h->volume_name));
|
||||||
|
if (strlen(volume_name) > strlen(h->volume_name))
|
||||||
|
fprintf(stderr, _("Label was truncated.\n"));
|
||||||
|
}
|
||||||
|
if (uuid || volume_name) {
|
||||||
|
if (volume_name)
|
||||||
|
printf("LABEL=%s, ", h->volume_name);
|
||||||
|
else
|
||||||
|
printf(_("no label, "));
|
||||||
|
#ifdef HAVE_uuid_uuid_h
|
||||||
|
if (uuid) {
|
||||||
|
char uuid_string[37];
|
||||||
|
uuid_unparse(uuid, uuid_string);
|
||||||
|
printf("UUID=%s\n", uuid_string);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
printf(_("no uuid\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find out what the maximum amount of swap space is that the kernel will
|
* Find out what the maximum amount of swap space is that the kernel will
|
||||||
* handle. This wouldn't matter if the kernel just used as much of the
|
* handle. This wouldn't matter if the kernel just used as much of the
|
||||||
|
@ -323,7 +379,7 @@ bit_test_and_clear (unsigned long *addr, unsigned int nr) {
|
||||||
static void
|
static void
|
||||||
usage(void) {
|
usage(void) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
_("Usage: %s [-c] [-v0|-v1] [-pPAGESZ] /dev/name [blocks]\n"),
|
_("Usage: %s [-c] [-v0|-v1] [-pPAGESZ] [-L label] /dev/name [blocks]\n"),
|
||||||
program_name);
|
program_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -448,8 +504,13 @@ main(int argc, char ** argv) {
|
||||||
int force = 0;
|
int force = 0;
|
||||||
char *block_count = 0;
|
char *block_count = 0;
|
||||||
char *pp;
|
char *pp;
|
||||||
|
char *opt_label = NULL;
|
||||||
|
char *uuid = NULL;
|
||||||
|
#ifdef HAVE_uuid_uuid_h
|
||||||
|
uuid_t uuid_dat;
|
||||||
|
#endif
|
||||||
|
|
||||||
program_name = (argc && *argv) ? argv[0] : "fsck.minix";
|
program_name = (argc && *argv) ? argv[0] : "mkswap";
|
||||||
if ((pp = strrchr(program_name, '/')) != NULL)
|
if ((pp = strrchr(program_name, '/')) != NULL)
|
||||||
program_name = pp+1;
|
program_name = pp+1;
|
||||||
|
|
||||||
|
@ -477,10 +538,16 @@ main(int argc, char ** argv) {
|
||||||
if (!*pp && i+1 < argc)
|
if (!*pp && i+1 < argc)
|
||||||
pp = argv[++i];
|
pp = argv[++i];
|
||||||
if (isnzdigit(*pp))
|
if (isnzdigit(*pp))
|
||||||
user_pagesize=atoi(pp);
|
user_pagesize = atoi(pp);
|
||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
|
case 'L':
|
||||||
|
pp = argv[i]+2;
|
||||||
|
if (!*pp && i+1 < argc)
|
||||||
|
pp = argv[++i];
|
||||||
|
opt_label = pp;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
version = atoi(argv[i]+2);
|
version = atoi(argv[i]+2);
|
||||||
break;
|
break;
|
||||||
|
@ -495,6 +562,11 @@ main(int argc, char ** argv) {
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_uuid_uuid_h
|
||||||
|
uuid_generate(uuid_dat);
|
||||||
|
uuid = uuid_dat;
|
||||||
|
#endif
|
||||||
|
|
||||||
init_signature_page(); /* get pagesize */
|
init_signature_page(); /* get pagesize */
|
||||||
|
|
||||||
if (!device_name) {
|
if (!device_name) {
|
||||||
|
@ -525,6 +597,10 @@ main(int argc, char ** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version == -1) {
|
if (version == -1) {
|
||||||
|
/* labels only for v1 */
|
||||||
|
if (opt_label)
|
||||||
|
version = 1;
|
||||||
|
else
|
||||||
/* use version 1 as default, if possible */
|
/* use version 1 as default, if possible */
|
||||||
if (PAGES <= V0_MAX_PAGES && PAGES > V1_MAX_PAGES)
|
if (PAGES <= V0_MAX_PAGES && PAGES > V1_MAX_PAGES)
|
||||||
version = 0;
|
version = 0;
|
||||||
|
@ -564,6 +640,13 @@ main(int argc, char ** argv) {
|
||||||
program_name, PAGES * pagesize / 1000);
|
program_name, PAGES * pagesize / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt_label && version == 0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
_("%s: error: label only with v1 swap area\n"),
|
||||||
|
program_name);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
DEV = open(device_name,O_RDWR);
|
DEV = open(device_name,O_RDWR);
|
||||||
if (DEV < 0 || fstat(DEV, &statbuf) < 0) {
|
if (DEV < 0 || fstat(DEV, &statbuf) < 0) {
|
||||||
perror(device_name);
|
perror(device_name);
|
||||||
|
@ -618,6 +701,9 @@ the -f option to force it.\n"),
|
||||||
version, (unsigned long long)goodpages * pagesize / 1000);
|
version, (unsigned long long)goodpages * pagesize / 1000);
|
||||||
write_signature((version == 0) ? "SWAP-SPACE" : "SWAPSPACE2");
|
write_signature((version == 0) ? "SWAP-SPACE" : "SWAPSPACE2");
|
||||||
|
|
||||||
|
if (version == 1)
|
||||||
|
write_uuid_and_label(uuid, opt_label);
|
||||||
|
|
||||||
offset = ((version == 0) ? 0 : 1024);
|
offset = ((version == 0) ? 0 : 1024);
|
||||||
if (lseek(DEV, offset, SEEK_SET) != offset)
|
if (lseek(DEV, offset, SEEK_SET) != offset)
|
||||||
die(_("unable to rewind swap-device"));
|
die(_("unable to rewind swap-device"));
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
struct swap_header_v1 {
|
||||||
|
char bootbits[1024]; /* Space for disklabel etc. */
|
||||||
|
unsigned int version;
|
||||||
|
unsigned int last_page;
|
||||||
|
unsigned int nr_badpages;
|
||||||
|
unsigned int padding[125];
|
||||||
|
unsigned int badpages[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct swap_header_v1_2 {
|
||||||
|
char bootbits[1024]; /* Space for disklabel etc. */
|
||||||
|
unsigned int version;
|
||||||
|
unsigned int last_page;
|
||||||
|
unsigned int nr_badpages;
|
||||||
|
unsigned char uuid[16];
|
||||||
|
char volume_name[16];
|
||||||
|
unsigned int padding[117];
|
||||||
|
unsigned int badpages[1];
|
||||||
|
};
|
|
@ -47,18 +47,19 @@ install: $(PROGS)
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(COMPILE) $<
|
$(COMPILE) $<
|
||||||
|
|
||||||
mount: mount.o fstab.o sundries.o realpath.o mntent.o version.o \
|
mount: mount.o fstab.o sundries.o xmalloc.o realpath.o mntent.o version.o \
|
||||||
get_label_uuid.o mount_by_label.o mount_blkid.o mount_guess_fstype.o \
|
get_label_uuid.o mount_by_label.o mount_blkid.o mount_guess_fstype.o \
|
||||||
getusername.o $(LIB)/setproctitle.o $(LIB)/env.o $(NFS_OBJS) $(LO_OBJS)
|
getusername.o $(LIB)/setproctitle.o $(LIB)/env.o $(NFS_OBJS) $(LO_OBJS)
|
||||||
$(LINK) $^ -o $@ $(BLKID_LIB)
|
$(LINK) $^ -o $@ $(BLKID_LIB)
|
||||||
|
|
||||||
umount: umount.o fstab.o sundries.o realpath.o mntent.o getusername.o \
|
umount: umount.o fstab.o sundries.o xmalloc.o realpath.o mntent.o \
|
||||||
get_label_uuid.o mount_by_label.o mount_blkid.o version.o \
|
getusername.o get_label_uuid.o mount_by_label.o mount_blkid.o \
|
||||||
$(LIB)/env.o $(LO_OBJS)
|
version.o $(LIB)/env.o $(LO_OBJS)
|
||||||
$(LINK) $^ -o $@ $(BLKID_LIB)
|
$(LINK) $^ -o $@ $(BLKID_LIB)
|
||||||
|
|
||||||
swapon: swapon.o version.o
|
swapon: swapon.o version.o xmalloc.o \
|
||||||
$(LINK) $^ -o $@
|
get_label_uuid.o mount_by_label.o mount_blkid.o
|
||||||
|
$(LINK) $^ -o $@ $(BLKID_LIB)
|
||||||
|
|
||||||
main_losetup.o: lomount.c
|
main_losetup.o: lomount.c
|
||||||
$(COMPILE) -DMAIN lomount.c -o $@
|
$(COMPILE) -DMAIN lomount.c -o $@
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "mntent.h"
|
#include "mntent.h"
|
||||||
#include "fstab.h"
|
#include "fstab.h"
|
||||||
#include "sundries.h" /* for xmalloc() etc */
|
#include "sundries.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
#include "mount_blkid.h"
|
#include "mount_blkid.h"
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
|
@ -411,6 +412,15 @@ setlkw_timeout (int sig) {
|
||||||
/* nothing, fcntl will fail anyway */
|
/* nothing, fcntl will fail anyway */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove lock file. */
|
||||||
|
void
|
||||||
|
unlock_mtab (void) {
|
||||||
|
if (we_created_lockfile) {
|
||||||
|
unlink (MOUNTED_LOCK);
|
||||||
|
we_created_lockfile = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the lock file.
|
/* Create the lock file.
|
||||||
The lock file will be removed if we catch a signal or when we exit. */
|
The lock file will be removed if we catch a signal or when we exit. */
|
||||||
/* The old code here used flock on a lock file /etc/mtab~ and deleted
|
/* The old code here used flock on a lock file /etc/mtab~ and deleted
|
||||||
|
@ -436,6 +446,8 @@ lock_mtab (void) {
|
||||||
int tries = 3;
|
int tries = 3;
|
||||||
char linktargetfile[MOUNTLOCK_LINKTARGET_LTH];
|
char linktargetfile[MOUNTLOCK_LINKTARGET_LTH];
|
||||||
|
|
||||||
|
at_die = unlock_mtab;
|
||||||
|
|
||||||
if (!signals_have_been_setup) {
|
if (!signals_have_been_setup) {
|
||||||
int sig = 0;
|
int sig = 0;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
@ -543,15 +555,6 @@ lock_mtab (void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove lock file. */
|
|
||||||
void
|
|
||||||
unlock_mtab (void) {
|
|
||||||
if (we_created_lockfile) {
|
|
||||||
unlink (MOUNTED_LOCK);
|
|
||||||
we_created_lockfile = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update the mtab.
|
* Update the mtab.
|
||||||
* Used by umount with null INSTEAD: remove the last DIR entry.
|
* Used by umount with null INSTEAD: remove the last DIR entry.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef HAVE_BLKID
|
#ifndef HAVE_BLKID
|
||||||
/*
|
/*
|
||||||
* Get label. Used by both mount and umount.
|
* Get label. Used by mount, umount and swapon.
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -8,8 +8,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "xmalloc.h"
|
||||||
#include "linux_fs.h"
|
#include "linux_fs.h"
|
||||||
#include "get_label_uuid.h"
|
#include "get_label_uuid.h"
|
||||||
|
#include "../disk-utils/swapheader.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See whether this device has (the magic of) a RAID superblock at the end.
|
* See whether this device has (the magic of) a RAID superblock at the end.
|
||||||
|
@ -60,15 +62,48 @@ reiserfs_magic_version(const char *magic) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
store_uuid(char *udest, char *usrc) {
|
||||||
|
if (usrc)
|
||||||
|
memcpy(udest, usrc, 16);
|
||||||
|
else
|
||||||
|
memset(udest, 0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
store_label(char **ldest, char *lsrc, int len) {
|
||||||
|
*ldest = xmalloc(len+1);
|
||||||
|
memset(*ldest, 0, len+1);
|
||||||
|
memcpy(*ldest, lsrc, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
is_v1_swap_partition(int fd, char **label, char *uuid) {
|
||||||
|
int n = getpagesize();
|
||||||
|
char *buf = xmalloc(n);
|
||||||
|
struct swap_header_v1_2 *p = (struct swap_header_v1_2 *) buf;
|
||||||
|
|
||||||
|
if (lseek(fd, 0, SEEK_SET) == 0
|
||||||
|
&& read(fd, buf, n) == n
|
||||||
|
&& !strncmp(buf+n-10, "SWAPSPACE2", 10)
|
||||||
|
&& p->version == 1) {
|
||||||
|
store_uuid(uuid, p->uuid);
|
||||||
|
store_label(label, p->volume_name, 16);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get both label and uuid.
|
* Get both label and uuid.
|
||||||
* For now, only ext2, ext3, xfs, ocfs, ocfs2, reiserfs are supported
|
* For now, only ext2, ext3, xfs, ocfs, ocfs2, reiserfs, swap are supported
|
||||||
|
*
|
||||||
|
* Return 0 on success.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_label_uuid(const char *device, char **label, char *uuid) {
|
get_label_uuid(const char *device, char **label, char *uuid) {
|
||||||
int fd;
|
int fd;
|
||||||
int rv = 1;
|
|
||||||
size_t namesize;
|
|
||||||
struct ext2_super_block e2sb;
|
struct ext2_super_block e2sb;
|
||||||
struct xfs_super_block xfsb;
|
struct xfs_super_block xfsb;
|
||||||
struct jfs_super_block jfssb;
|
struct jfs_super_block jfssb;
|
||||||
|
@ -76,47 +111,50 @@ get_label_uuid(const char *device, char **label, char *uuid) {
|
||||||
struct ocfs_volume_label olbl;
|
struct ocfs_volume_label olbl;
|
||||||
struct ocfs2_super_block osb;
|
struct ocfs2_super_block osb;
|
||||||
struct reiserfs_super_block reiserfssb;
|
struct reiserfs_super_block reiserfssb;
|
||||||
|
int blksize;
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
fd = open(device, O_RDONLY);
|
fd = open(device, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return rv;
|
return -1;
|
||||||
|
|
||||||
/* If there is a RAID partition, or an error, ignore this partition */
|
/* If there is a RAID partition, or an error, ignore this partition */
|
||||||
if (is_raid_partition(fd)) {
|
if (is_raid_partition(fd)) {
|
||||||
close(fd);
|
rv = 1;
|
||||||
return rv;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_v1_swap_partition(fd, label, uuid))
|
||||||
|
goto done;
|
||||||
|
|
||||||
if (lseek(fd, 1024, SEEK_SET) == 1024
|
if (lseek(fd, 1024, SEEK_SET) == 1024
|
||||||
&& read(fd, (char *) &e2sb, sizeof(e2sb)) == sizeof(e2sb)
|
&& read(fd, (char *) &e2sb, sizeof(e2sb)) == sizeof(e2sb)
|
||||||
&& (ext2magic(e2sb) == EXT2_SUPER_MAGIC)) {
|
&& (ext2magic(e2sb) == EXT2_SUPER_MAGIC)) {
|
||||||
memcpy(uuid, e2sb.s_uuid, sizeof(e2sb.s_uuid));
|
store_uuid(uuid, e2sb.s_uuid);
|
||||||
namesize = sizeof(e2sb.s_volume_name);
|
store_label(label, e2sb.s_volume_name,
|
||||||
if ((*label = calloc(namesize + 1, 1)) != NULL)
|
sizeof(e2sb.s_volume_name));
|
||||||
memcpy(*label, e2sb.s_volume_name, namesize);
|
goto done;
|
||||||
rv = 0;
|
|
||||||
}
|
}
|
||||||
else if (lseek(fd, 0, SEEK_SET) == 0
|
|
||||||
|
if (lseek(fd, 0, SEEK_SET) == 0
|
||||||
&& read(fd, (char *) &xfsb, sizeof(xfsb)) == sizeof(xfsb)
|
&& read(fd, (char *) &xfsb, sizeof(xfsb)) == sizeof(xfsb)
|
||||||
&& (strncmp(xfsb.s_magic, XFS_SUPER_MAGIC, 4) == 0)) {
|
&& (strncmp(xfsb.s_magic, XFS_SUPER_MAGIC, 4) == 0)) {
|
||||||
memcpy(uuid, xfsb.s_uuid, sizeof(xfsb.s_uuid));
|
store_uuid(uuid, xfsb.s_uuid);
|
||||||
namesize = sizeof(xfsb.s_fname);
|
store_label(label, xfsb.s_fname, sizeof(xfsb.s_fname));
|
||||||
if ((*label = calloc(namesize + 1, 1)) != NULL)
|
goto done;
|
||||||
memcpy(*label, xfsb.s_fname, namesize);
|
|
||||||
rv = 0;
|
|
||||||
}
|
}
|
||||||
else if (lseek(fd, 0, SEEK_SET) == 0
|
|
||||||
|
if (lseek(fd, 0, SEEK_SET) == 0
|
||||||
&& read(fd, (char *) &ovh, sizeof(ovh)) == sizeof(ovh)
|
&& read(fd, (char *) &ovh, sizeof(ovh)) == sizeof(ovh)
|
||||||
&& (strncmp(ovh.signature, OCFS_MAGIC, sizeof(OCFS_MAGIC)) == 0)
|
&& (strncmp(ovh.signature, OCFS_MAGIC, sizeof(OCFS_MAGIC)) == 0)
|
||||||
&& (lseek(fd, 512, SEEK_SET) == 512)
|
&& (lseek(fd, 512, SEEK_SET) == 512)
|
||||||
&& read(fd, (char *) &olbl, sizeof(olbl)) == sizeof(olbl)) {
|
&& read(fd, (char *) &olbl, sizeof(olbl)) == sizeof(olbl)) {
|
||||||
uuid[0] = '\0';
|
store_uuid(uuid, NULL);
|
||||||
namesize = ocfslabellen(olbl);
|
store_label(label, olbl.label, ocfslabellen(olbl));
|
||||||
if ((*label = calloc(namesize + 1, 1)) != NULL)
|
goto done;
|
||||||
memcpy(*label, olbl.label, namesize);
|
|
||||||
rv = 0;
|
|
||||||
}
|
}
|
||||||
else if (lseek(fd, JFS_SUPER1_OFF, SEEK_SET) == JFS_SUPER1_OFF
|
|
||||||
|
if (lseek(fd, JFS_SUPER1_OFF, SEEK_SET) == JFS_SUPER1_OFF
|
||||||
&& read(fd, (char *) &jfssb, sizeof(jfssb)) == sizeof(jfssb)
|
&& read(fd, (char *) &jfssb, sizeof(jfssb)) == sizeof(jfssb)
|
||||||
&& (strncmp(jfssb.s_magic, JFS_MAGIC, 4) == 0)) {
|
&& (strncmp(jfssb.s_magic, JFS_MAGIC, 4) == 0)) {
|
||||||
|
|
||||||
|
@ -136,55 +174,47 @@ get_label_uuid(const char *device, char **label, char *uuid) {
|
||||||
|
|
||||||
if (assemble4le(jfssb.s_version) == 1 &&
|
if (assemble4le(jfssb.s_version) == 1 &&
|
||||||
strncmp(jfssb.s_label, jfssb.s_fpack, 11) != 0) {
|
strncmp(jfssb.s_label, jfssb.s_fpack, 11) != 0) {
|
||||||
memset(uuid, 0, 16);
|
store_uuid(uuid, NULL);
|
||||||
namesize = sizeof(jfssb.s_fpack);
|
store_label(label, jfssb.s_fpack,
|
||||||
if ((*label = calloc(namesize + 1, 1)) != NULL)
|
sizeof(jfssb.s_fpack));
|
||||||
memcpy(*label, jfssb.s_fpack, namesize);
|
|
||||||
} else {
|
} else {
|
||||||
memcpy(uuid, jfssb.s_uuid, sizeof(jfssb.s_uuid));
|
store_uuid(uuid, jfssb.s_uuid);
|
||||||
namesize = sizeof(jfssb.s_label);
|
store_label(label, jfssb.s_label,
|
||||||
if ((*label = calloc(namesize + 1, 1)) != NULL)
|
sizeof(jfssb.s_label));
|
||||||
memcpy(*label, jfssb.s_label, namesize);
|
|
||||||
}
|
}
|
||||||
rv = 0;
|
goto done;
|
||||||
}
|
}
|
||||||
else if (lseek(fd, REISERFS_DISK_OFFSET_IN_BYTES, SEEK_SET)
|
|
||||||
== REISERFS_DISK_OFFSET_IN_BYTES
|
if (lseek(fd, REISERFS_DISK_OFFSET_IN_BYTES, SEEK_SET)
|
||||||
|
== REISERFS_DISK_OFFSET_IN_BYTES
|
||||||
&& read(fd, (char *) &reiserfssb, sizeof(reiserfssb))
|
&& read(fd, (char *) &reiserfssb, sizeof(reiserfssb))
|
||||||
== sizeof(reiserfssb)
|
== sizeof(reiserfssb)
|
||||||
/* Only 3.6.x format supers have labels or uuids.
|
/* Only 3.6.x format supers have labels or uuids.
|
||||||
Label and UUID can be set by reiserfstune -l/-u. */
|
Label and UUID can be set by reiserfstune -l/-u. */
|
||||||
&& reiserfs_magic_version(reiserfssb.s_magic) > 1) {
|
&& reiserfs_magic_version(reiserfssb.s_magic) > 1) {
|
||||||
namesize = sizeof (reiserfssb.s_label);
|
store_uuid(uuid, reiserfssb.s_uuid);
|
||||||
if ((*label = calloc(namesize + 1, 1)) != NULL)
|
store_label(label, reiserfssb.s_label,
|
||||||
memcpy(*label, reiserfssb.s_label, namesize);
|
sizeof(reiserfssb.s_label));
|
||||||
memcpy(uuid, reiserfssb.s_uuid, sizeof (reiserfssb.s_uuid));
|
goto done;
|
||||||
rv = 0;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
int blksize, blkoff;
|
|
||||||
|
|
||||||
for (blksize = OCFS2_MIN_BLOCKSIZE;
|
for (blksize = OCFS2_MIN_BLOCKSIZE;
|
||||||
blksize <= OCFS2_MAX_BLOCKSIZE;
|
blksize <= OCFS2_MAX_BLOCKSIZE;
|
||||||
blksize <<= 1) {
|
blksize <<= 1) {
|
||||||
blkoff = blksize * OCFS2_SUPER_BLOCK_BLKNO;
|
int blkoff = blksize * OCFS2_SUPER_BLOCK_BLKNO;
|
||||||
if (lseek(fd, blkoff, SEEK_SET) == blkoff
|
|
||||||
&& read(fd, (char *) &osb, sizeof(osb))
|
if (lseek(fd, blkoff, SEEK_SET) == blkoff
|
||||||
== sizeof(osb)
|
&& read(fd, (char *) &osb, sizeof(osb)) == sizeof(osb)
|
||||||
&& strncmp(osb.signature,
|
&& strncmp(osb.signature,
|
||||||
OCFS2_SUPER_BLOCK_SIGNATURE,
|
OCFS2_SUPER_BLOCK_SIGNATURE,
|
||||||
sizeof(OCFS2_SUPER_BLOCK_SIGNATURE))
|
sizeof(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) {
|
||||||
== 0) {
|
store_uuid(uuid, osb.s_uuid);
|
||||||
memcpy(uuid, osb.s_uuid, sizeof(osb.s_uuid));
|
store_label(label, osb.s_label, sizeof(osb.s_label));
|
||||||
namesize = sizeof(osb.s_label);
|
goto done;
|
||||||
if ((*label = calloc(namesize, 1)) != NULL)
|
|
||||||
memcpy(*label, osb.s_label, namesize);
|
|
||||||
rv = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rv = 1;
|
||||||
|
done:
|
||||||
close(fd);
|
close(fd);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,7 +242,7 @@ int
|
||||||
set_loop(const char *device, const char *file, unsigned long long offset,
|
set_loop(const char *device, const char *file, unsigned long long offset,
|
||||||
const char *encryption, int pfd, int *loopro) {
|
const char *encryption, int pfd, int *loopro) {
|
||||||
struct loop_info64 loopinfo64;
|
struct loop_info64 loopinfo64;
|
||||||
int fd, ffd, mode, i, n;
|
int fd, ffd, mode, i;
|
||||||
char *pass;
|
char *pass;
|
||||||
|
|
||||||
mode = (*loopro ? O_RDONLY : O_RDWR);
|
mode = (*loopro ? O_RDONLY : O_RDWR);
|
||||||
|
@ -299,11 +299,10 @@ set_loop(const char *device, const char *file, unsigned long long offset,
|
||||||
default:
|
default:
|
||||||
pass = xgetpass(pfd, _("Password: "));
|
pass = xgetpass(pfd, _("Password: "));
|
||||||
gotpass:
|
gotpass:
|
||||||
|
memset(loopinfo64.lo_encrypt_key, 0, LO_KEY_SIZE);
|
||||||
xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE);
|
xstrncpy(loopinfo64.lo_encrypt_key, pass, LO_KEY_SIZE);
|
||||||
n = strlen(pass);
|
memset(pass, 0, strlen(pass));
|
||||||
memset(pass, 0, n);
|
loopinfo64.lo_encrypt_key_size = LO_KEY_SIZE;
|
||||||
loopinfo64.lo_encrypt_key_size =
|
|
||||||
(n < LO_KEY_SIZE) ? n : LO_KEY_SIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
|
if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "mount_blkid.h"
|
#include "mount_blkid.h"
|
||||||
#include "mount_constants.h"
|
#include "mount_constants.h"
|
||||||
#include "sundries.h"
|
#include "sundries.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
#include "mntent.h"
|
#include "mntent.h"
|
||||||
#include "fstab.h"
|
#include "fstab.h"
|
||||||
#include "lomount.h"
|
#include "lomount.h"
|
||||||
|
|
|
@ -74,6 +74,8 @@ mount_get_devname_by_uuid(const char *uuid) {
|
||||||
return get_spec_by_uuid(uuid);
|
return get_spec_by_uuid(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern char *progname;
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
mount_get_devname_by_label(const char *volumelabel) {
|
mount_get_devname_by_label(const char *volumelabel) {
|
||||||
const char *spec, *spec2;
|
const char *spec, *spec2;
|
||||||
|
@ -82,9 +84,8 @@ mount_get_devname_by_label(const char *volumelabel) {
|
||||||
spec2 = second_occurrence_of_vol_label(volumelabel);
|
spec2 = second_occurrence_of_vol_label(volumelabel);
|
||||||
if (spec2)
|
if (spec2)
|
||||||
die (EX_FAIL,
|
die (EX_FAIL,
|
||||||
_("mount: the label %s occurs on "
|
_("%s: error: the label %s occurs on both %s and %s\n"),
|
||||||
"both %s and %s - not mounted\n"),
|
progname, volumelabel, spec, spec2);
|
||||||
volumelabel, spec, spec2);
|
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@
|
||||||
#define EVMS_VOLUME_NAME_SIZE 127
|
#define EVMS_VOLUME_NAME_SIZE 127
|
||||||
#define PROC_EVMS_VOLUMES "/proc/evms/volumes"
|
#define PROC_EVMS_VOLUMES "/proc/evms/volumes"
|
||||||
|
|
||||||
|
extern char *progname;
|
||||||
|
|
||||||
static struct uuidCache_s {
|
static struct uuidCache_s {
|
||||||
struct uuidCache_s *next;
|
struct uuidCache_s *next;
|
||||||
char uuid[16];
|
char uuid[16];
|
||||||
|
@ -82,7 +84,7 @@ uuidcache_init_lvm(void) {
|
||||||
sprintf(buffer, "%s/%s/LVs", VG_DIR, vg_iter->d_name);
|
sprintf(buffer, "%s/%s/LVs", VG_DIR, vg_iter->d_name);
|
||||||
lv_list = opendir(buffer);
|
lv_list = opendir(buffer);
|
||||||
if (lv_list == NULL) {
|
if (lv_list == NULL) {
|
||||||
perror("mount (init_lvm)");
|
perror("uuidcache_init_lvm");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
seekdir(lv_list, 2);
|
seekdir(lv_list, 2);
|
||||||
|
@ -187,9 +189,9 @@ uuidcache_init(void) {
|
||||||
if (!procpt) {
|
if (!procpt) {
|
||||||
static int warn = 0;
|
static int warn = 0;
|
||||||
if (!warn++)
|
if (!warn++)
|
||||||
error (_("mount: could not open %s, so UUID and LABEL "
|
error (_("%s: could not open %s, so UUID and LABEL "
|
||||||
"conversion cannot be done.\n"),
|
"conversion cannot be done.\n"),
|
||||||
PROC_PARTITIONS);
|
progname, PROC_PARTITIONS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -310,7 +312,7 @@ get_spec_by_uuid(const char *s) {
|
||||||
return get_spec_by_x(UUID, uuid);
|
return get_spec_by_x(UUID, uuid);
|
||||||
|
|
||||||
bad_uuid:
|
bad_uuid:
|
||||||
die(EX_USAGE, _("mount: bad UUID"));
|
die(EX_USAGE, _("%s: bad UUID"), progname);
|
||||||
return NULL; /* just for gcc */
|
return NULL; /* just for gcc */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,46 +18,6 @@
|
||||||
#include "nfsmount.h"
|
#include "nfsmount.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
|
|
||||||
void *
|
|
||||||
xmalloc (size_t size) {
|
|
||||||
void *t;
|
|
||||||
|
|
||||||
if (size == 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
t = malloc (size);
|
|
||||||
if (t == NULL)
|
|
||||||
die (EX_SYSERR, _("not enough memory"));
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
xrealloc (void *p, size_t size) {
|
|
||||||
void *t;
|
|
||||||
|
|
||||||
t = realloc(p, size);
|
|
||||||
if (t == NULL)
|
|
||||||
die (EX_SYSERR, _("not enough memory"));
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
xstrdup (const char *s) {
|
|
||||||
char *t;
|
|
||||||
|
|
||||||
if (s == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
t = strdup (s);
|
|
||||||
|
|
||||||
if (t == NULL)
|
|
||||||
die (EX_SYSERR, _("not enough memory"));
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
xstrndup (const char *s, int n) {
|
xstrndup (const char *s, int n) {
|
||||||
char *t;
|
char *t;
|
||||||
|
@ -147,20 +107,6 @@ error (const char *fmt, ...) {
|
||||||
free (fmt2);
|
free (fmt2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fatal error. Print message and exit. */
|
|
||||||
void
|
|
||||||
die (int err, const char *fmt, ...) {
|
|
||||||
va_list args;
|
|
||||||
|
|
||||||
va_start (args, fmt);
|
|
||||||
vfprintf (stderr, fmt, args);
|
|
||||||
fprintf (stderr, "\n");
|
|
||||||
va_end (args);
|
|
||||||
|
|
||||||
unlock_mtab ();
|
|
||||||
exit (err);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* True if fstypes match. Null *TYPES means match anything,
|
/* True if fstypes match. Null *TYPES means match anything,
|
||||||
except that swap types always return false. */
|
except that swap types always return false. */
|
||||||
/* Accept nonfs,proc,devpts and nonfs,noproc,nodevpts
|
/* Accept nonfs,proc,devpts and nonfs,noproc,nodevpts
|
||||||
|
|
|
@ -26,7 +26,6 @@ void error (const char *fmt, ...);
|
||||||
int matching_type (const char *type, const char *types);
|
int matching_type (const char *type, const char *types);
|
||||||
int matching_opts (const char *options, const char *test_opts);
|
int matching_opts (const char *options, const char *test_opts);
|
||||||
void *xmalloc (size_t size);
|
void *xmalloc (size_t size);
|
||||||
void *xrealloc (void *t, size_t size);
|
|
||||||
char *xstrdup (const char *s);
|
char *xstrdup (const char *s);
|
||||||
char *xstrndup (const char *s, int n);
|
char *xstrndup (const char *s, int n);
|
||||||
char *xstrconcat2 (const char *, const char *);
|
char *xstrconcat2 (const char *, const char *);
|
||||||
|
|
|
@ -58,6 +58,15 @@ swapon, swapoff \- enable/disable devices and files for paging and swapping
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B Swapon
|
.B Swapon
|
||||||
is used to specify devices on which paging and swapping are to take place.
|
is used to specify devices on which paging and swapping are to take place.
|
||||||
|
|
||||||
|
The device or file used is given by the
|
||||||
|
.I specialfile
|
||||||
|
parameter. It may be of the form
|
||||||
|
.BI \-L " label"
|
||||||
|
or
|
||||||
|
.BI \-U " uuid"
|
||||||
|
to indicate a device by label or uuid.
|
||||||
|
|
||||||
Calls to
|
Calls to
|
||||||
.B swapon
|
.B swapon
|
||||||
normally occur in the system multi-user initialization file
|
normally occur in the system multi-user initialization file
|
||||||
|
@ -67,16 +76,6 @@ is interleaved across several devices and files.
|
||||||
|
|
||||||
Normally, the first form is used:
|
Normally, the first form is used:
|
||||||
.TP
|
.TP
|
||||||
.B \-h
|
|
||||||
Provide help
|
|
||||||
.TP
|
|
||||||
.B \-V
|
|
||||||
Display version
|
|
||||||
.TP
|
|
||||||
.B \-s
|
|
||||||
Display swap usage summary by device. Equivalent to "cat /proc/swaps".
|
|
||||||
Not available before Linux 2.1.25.
|
|
||||||
.TP
|
|
||||||
.B \-a
|
.B \-a
|
||||||
All devices marked as ``swap'' swap devices in
|
All devices marked as ``swap'' swap devices in
|
||||||
.I /etc/fstab
|
.I /etc/fstab
|
||||||
|
@ -88,8 +87,17 @@ When
|
||||||
.B \-a
|
.B \-a
|
||||||
is used with swapon,
|
is used with swapon,
|
||||||
.B \-e
|
.B \-e
|
||||||
makes swapon silently skip devices that
|
makes swapon silently skip devices that do not exist.
|
||||||
do not exist.
|
.TP
|
||||||
|
.B \-h
|
||||||
|
Provide help
|
||||||
|
.TP
|
||||||
|
.BI \-L " label"
|
||||||
|
Use the partition that has the specified
|
||||||
|
.IR label .
|
||||||
|
(For this, access to
|
||||||
|
.I /proc/partitions
|
||||||
|
is needed.)
|
||||||
.TP
|
.TP
|
||||||
.BI \-p " priority"
|
.BI \-p " priority"
|
||||||
Specify priority for
|
Specify priority for
|
||||||
|
@ -98,7 +106,8 @@ This option is only available if
|
||||||
.B swapon
|
.B swapon
|
||||||
was compiled under and is used under a 1.3.2 or later kernel.
|
was compiled under and is used under a 1.3.2 or later kernel.
|
||||||
.I priority
|
.I priority
|
||||||
is a value between 0 and 32767. See
|
is a value between 0 and 32767. Higher numbers indicate higher
|
||||||
|
priority. See
|
||||||
.BR swapon (2)
|
.BR swapon (2)
|
||||||
for a full description of swap priorities. Add
|
for a full description of swap priorities. Add
|
||||||
.BI pri= value
|
.BI pri= value
|
||||||
|
@ -107,8 +116,22 @@ to the option field of
|
||||||
for use with
|
for use with
|
||||||
.BR "swapon -a" .
|
.BR "swapon -a" .
|
||||||
.TP
|
.TP
|
||||||
|
.B \-s
|
||||||
|
Display swap usage summary by device. Equivalent to "cat /proc/swaps".
|
||||||
|
Not available before Linux 2.1.25.
|
||||||
|
.TP
|
||||||
|
.BI \-U " uuid"
|
||||||
|
Use the partition that has the specified
|
||||||
|
.IR uuid .
|
||||||
|
(For this, access to
|
||||||
|
.I /proc/partitions
|
||||||
|
is needed.)
|
||||||
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
Be verbose.
|
Be verbose.
|
||||||
|
.TP
|
||||||
|
.B \-V
|
||||||
|
Display version
|
||||||
.PP
|
.PP
|
||||||
.B Swapoff
|
.B Swapoff
|
||||||
disables swapping on the specified devices and files.
|
disables swapping on the specified devices and files.
|
||||||
|
|
240
mount/swapon.c
240
mount/swapon.c
|
@ -11,9 +11,12 @@
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include "xmalloc.h"
|
||||||
#include "swap_constants.h"
|
#include "swap_constants.h"
|
||||||
#include "swapargs.h"
|
#include "swapargs.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
|
#include "mount_blkid.h"
|
||||||
|
#include "mount_by_label.h"
|
||||||
|
|
||||||
#define streq(s, t) (strcmp ((s), (t)) == 0)
|
#define streq(s, t) (strcmp ((s), (t)) == 0)
|
||||||
|
|
||||||
|
@ -32,7 +35,7 @@ int priority = -1; /* non-prioritized swap by default */
|
||||||
int ifexists = 0;
|
int ifexists = 0;
|
||||||
|
|
||||||
extern char version[];
|
extern char version[];
|
||||||
static char *program_name;
|
char *progname;
|
||||||
|
|
||||||
static struct option longswaponopts[] = {
|
static struct option longswaponopts[] = {
|
||||||
/* swapon only */
|
/* swapon only */
|
||||||
|
@ -53,9 +56,9 @@ static void
|
||||||
swapon_usage(FILE *fp, int n) {
|
swapon_usage(FILE *fp, int n) {
|
||||||
fprintf(fp, _("usage: %s [-hV]\n"
|
fprintf(fp, _("usage: %s [-hV]\n"
|
||||||
" %s -a [-e] [-v]\n"
|
" %s -a [-e] [-v]\n"
|
||||||
" %s [-v] [-p priority] special ...\n"
|
" %s [-v] [-p priority] special|LABEL=volume_name ...\n"
|
||||||
" %s [-s]\n"),
|
" %s [-s]\n"),
|
||||||
program_name, program_name, program_name, program_name);
|
progname, progname, progname, progname);
|
||||||
exit(n);
|
exit(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +67,7 @@ swapoff_usage(FILE *fp, int n) {
|
||||||
fprintf(fp, _("usage: %s [-hV]\n"
|
fprintf(fp, _("usage: %s [-hV]\n"
|
||||||
" %s -a [-v]\n"
|
" %s -a [-v]\n"
|
||||||
" %s [-v] special ...\n"),
|
" %s [-v] special ...\n"),
|
||||||
program_name, program_name, program_name);
|
progname, progname, progname);
|
||||||
exit(n);
|
exit(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +135,7 @@ read_proc_swaps(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
is_in_proc_swaps(char *fname) {
|
is_in_proc_swaps(const char *fname) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < numSwaps; i++)
|
for (i = 0; i < numSwaps; i++)
|
||||||
|
@ -149,7 +152,7 @@ display_summary(void)
|
||||||
|
|
||||||
if ((swaps = fopen(PROC_SWAPS, "r")) == NULL) {
|
if ((swaps = fopen(PROC_SWAPS, "r")) == NULL) {
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
fprintf(stderr, "%s: %s: %s\n", program_name, PROC_SWAPS,
|
fprintf(stderr, "%s: %s: %s\n", progname, PROC_SWAPS,
|
||||||
strerror(errsv));
|
strerror(errsv));
|
||||||
return -1 ;
|
return -1 ;
|
||||||
}
|
}
|
||||||
|
@ -162,17 +165,25 @@ display_summary(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_swapon(const char *special, int prio) {
|
do_swapon(const char *orig_special, int prio) {
|
||||||
int status;
|
int status;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
const char *special;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf(_("%s on %s\n"), program_name, special);
|
printf(_("%s on %s\n"), progname, orig_special);
|
||||||
|
|
||||||
|
special = mount_get_devname(orig_special);
|
||||||
|
if (!special) {
|
||||||
|
fprintf(stderr, _("%s: cannot find the device for %s\n"),
|
||||||
|
progname, orig_special);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (stat(special, &st) < 0) {
|
if (stat(special, &st) < 0) {
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
fprintf(stderr, _("swapon: cannot stat %s: %s\n"),
|
fprintf(stderr, _("%s: cannot stat %s: %s\n"),
|
||||||
special, strerror(errsv));
|
progname, special, strerror(errsv));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,10 +193,10 @@ do_swapon(const char *special, int prio) {
|
||||||
int permMask = (S_ISBLK(st.st_mode) ? 07007 : 07077);
|
int permMask = (S_ISBLK(st.st_mode) ? 07007 : 07077);
|
||||||
|
|
||||||
if ((st.st_mode & permMask) != 0) {
|
if ((st.st_mode & permMask) != 0) {
|
||||||
fprintf(stderr, _("swapon: warning: %s has "
|
fprintf(stderr, _("%s: warning: %s has "
|
||||||
"insecure permissions %04o, "
|
"insecure permissions %04o, "
|
||||||
"%04o suggested\n"),
|
"%04o suggested\n"),
|
||||||
special, st.st_mode & 07777,
|
progname, special, st.st_mode & 07777,
|
||||||
~permMask & 0666);
|
~permMask & 0666);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,9 +205,9 @@ do_swapon(const char *special, int prio) {
|
||||||
if (S_ISREG(st.st_mode)) {
|
if (S_ISREG(st.st_mode)) {
|
||||||
if (st.st_blocks * 512 < st.st_size) {
|
if (st.st_blocks * 512 < st.st_size) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
_("swapon: Skipping file %s - it appears "
|
_("%s: Skipping file %s - it appears "
|
||||||
"to have holes.\n"),
|
"to have holes.\n"),
|
||||||
special);
|
progname, special);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,17 +232,42 @@ do_swapon(const char *special, int prio) {
|
||||||
#endif
|
#endif
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
fprintf(stderr, "%s: %s: %s\n", program_name,
|
fprintf(stderr, "%s: %s: %s\n",
|
||||||
special, strerror(errsv));
|
progname, orig_special, strerror(errsv));
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_swapoff(const char *special, int quiet) {
|
cannot_find(const char *special) {
|
||||||
|
fprintf(stderr, _("%s: cannot find the device for %s\n"),
|
||||||
|
progname, special);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
swapon_by_label(const char *label, int prio) {
|
||||||
|
const char *special = mount_get_devname_by_label(label);
|
||||||
|
return special ? do_swapon(special, prio) : cannot_find(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
swapon_by_uuid(const char *uuid, int prio) {
|
||||||
|
const char *special = mount_get_devname_by_uuid(uuid);
|
||||||
|
return special ? do_swapon(special, prio) : cannot_find(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
do_swapoff(const char *orig_special, int quiet) {
|
||||||
|
const char *special;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf(_("%s on %s\n"), program_name, special);
|
printf(_("%s on %s\n"), progname, orig_special);
|
||||||
|
|
||||||
|
special = mount_get_devname(orig_special);
|
||||||
|
if (!special)
|
||||||
|
return cannot_find(orig_special);
|
||||||
|
|
||||||
if (swapoff(special) == 0)
|
if (swapoff(special) == 0)
|
||||||
return 0; /* success */
|
return 0; /* success */
|
||||||
|
@ -242,22 +278,96 @@ do_swapoff(const char *special, int quiet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!quiet || errno == ENOMEM) {
|
if (!quiet || errno == ENOMEM) {
|
||||||
int errsv = errno;
|
fprintf(stderr, "%s: %s: %s\n",
|
||||||
fprintf(stderr, "%s: %s: %s\n", program_name,
|
progname, orig_special, strerror(errno));
|
||||||
special, strerror(errsv));
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
main_swapon(int argc, char *argv[]) {
|
swapoff_by_label(const char *label, int quiet) {
|
||||||
|
const char *special = mount_get_devname_by_label(label);
|
||||||
|
return special ? do_swapoff(special, quiet) : cannot_find(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
swapoff_by_uuid(const char *uuid, int quiet) {
|
||||||
|
const char *special = mount_get_devname_by_uuid(uuid);
|
||||||
|
return special ? do_swapoff(special, quiet) : cannot_find(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
swapon_all(void) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct mntent *fstab;
|
struct mntent *fstab;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
int c;
|
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "ahep:svV",
|
read_proc_swaps();
|
||||||
longswaponopts, NULL)) != -1) {
|
|
||||||
|
fp = setmntent(_PATH_FSTAB, "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
int errsv = errno;
|
||||||
|
fprintf(stderr, _("%s: cannot open %s: %s\n"),
|
||||||
|
progname, _PATH_FSTAB, strerror(errsv));
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((fstab = getmntent(fp)) != NULL) {
|
||||||
|
const char *orig_special = fstab->mnt_fsname;
|
||||||
|
const char *special;
|
||||||
|
int skip = 0;
|
||||||
|
int pri = priority;
|
||||||
|
|
||||||
|
if (!streq(fstab->mnt_type, MNTTYPE_SWAP))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
special = mount_get_devname(orig_special);
|
||||||
|
if (!special)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!is_in_proc_swaps(special) &&
|
||||||
|
(!ifexists || !access(special, R_OK))) {
|
||||||
|
/* parse mount options; */
|
||||||
|
char *opt, *opts = strdup(fstab->mnt_opts);
|
||||||
|
|
||||||
|
for (opt = strtok(opts, ","); opt != NULL;
|
||||||
|
opt = strtok(NULL, ",")) {
|
||||||
|
if (strncmp(opt, "pri=", 4) == 0)
|
||||||
|
pri = atoi(opt+4);
|
||||||
|
if (strcmp(opt, "noauto") == 0)
|
||||||
|
skip = 1;
|
||||||
|
}
|
||||||
|
if (!skip)
|
||||||
|
status |= do_swapon(special, pri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char **llist = NULL;
|
||||||
|
static int llct = 0;
|
||||||
|
static const char **ulist = NULL;
|
||||||
|
static int ulct = 0;
|
||||||
|
|
||||||
|
static void addl(const char *label) {
|
||||||
|
llist = (const char **) xrealloc(llist, (++llct) * sizeof(char *));
|
||||||
|
llist[llct-1] = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addu(const char *uuid) {
|
||||||
|
ulist = (const char **) xrealloc(ulist, (++ulct) * sizeof(char *));
|
||||||
|
ulist[ulct-1] = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
main_swapon(int argc, char *argv[]) {
|
||||||
|
int status = 0;
|
||||||
|
int c, i;
|
||||||
|
|
||||||
|
while ((c = getopt_long(argc, argv, "ahep:svVL:U:",
|
||||||
|
longswaponopts, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a': /* all */
|
case 'a': /* all */
|
||||||
++all;
|
++all;
|
||||||
|
@ -268,6 +378,12 @@ main_swapon(int argc, char *argv[]) {
|
||||||
case 'p': /* priority */
|
case 'p': /* priority */
|
||||||
priority = atoi(optarg);
|
priority = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'L':
|
||||||
|
addl(optarg);
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
addu(optarg);
|
||||||
|
break;
|
||||||
case 'e': /* ifexists */
|
case 'e': /* ifexists */
|
||||||
ifexists = 1;
|
ifexists = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -278,7 +394,7 @@ main_swapon(int argc, char *argv[]) {
|
||||||
++verbose;
|
++verbose;
|
||||||
break;
|
break;
|
||||||
case 'V': /* version */
|
case 'V': /* version */
|
||||||
printf("%s: %s\n", program_name, version);
|
printf("%s: %s\n", progname, version);
|
||||||
exit(0);
|
exit(0);
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
@ -289,46 +405,20 @@ main_swapon(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (!all && *argv == NULL)
|
if (!all && !llct && !ulct && *argv == NULL)
|
||||||
swapon_usage(stderr, 2);
|
swapon_usage(stderr, 2);
|
||||||
|
|
||||||
if (ifexists && (!all || strcmp(program_name, "swapon")))
|
if (ifexists && (!all || strcmp(progname, "swapon")))
|
||||||
swapon_usage(stderr, 1);
|
swapon_usage(stderr, 1);
|
||||||
|
|
||||||
if (all) {
|
if (all)
|
||||||
read_proc_swaps();
|
status |= swapon_all();
|
||||||
|
|
||||||
fp = setmntent(_PATH_FSTAB, "r");
|
for (i = 0; i < llct; i++)
|
||||||
if (fp == NULL) {
|
status |= swapon_by_label(llist[i], priority);
|
||||||
int errsv = errno;
|
|
||||||
fprintf(stderr, _("%s: cannot open %s: %s\n"),
|
|
||||||
program_name, _PATH_FSTAB, strerror(errsv));
|
|
||||||
exit(2);
|
|
||||||
}
|
|
||||||
while ((fstab = getmntent(fp)) != NULL) {
|
|
||||||
char *special = fstab->mnt_fsname;
|
|
||||||
int skip = 0;
|
|
||||||
int pri = priority;
|
|
||||||
|
|
||||||
if (streq(fstab->mnt_type, MNTTYPE_SWAP) &&
|
for (i = 0; i < ulct; i++)
|
||||||
!is_in_proc_swaps(special)
|
status |= swapon_by_uuid(ulist[i], priority);
|
||||||
&& (!ifexists || !access(special, R_OK))) {
|
|
||||||
/* parse mount options; */
|
|
||||||
char *opt, *opts = strdup(fstab->mnt_opts);
|
|
||||||
|
|
||||||
for (opt = strtok(opts, ","); opt != NULL;
|
|
||||||
opt = strtok(NULL, ",")) {
|
|
||||||
if (strncmp(opt, "pri=", 4) == 0)
|
|
||||||
pri = atoi(opt+4);
|
|
||||||
if (strcmp(opt, "noauto") == 0)
|
|
||||||
skip = 1;
|
|
||||||
}
|
|
||||||
if (!skip)
|
|
||||||
status |= do_swapon(special, pri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*argv != NULL)
|
while (*argv != NULL)
|
||||||
status |= do_swapon(*argv++, priority);
|
status |= do_swapon(*argv++, priority);
|
||||||
|
@ -343,7 +433,7 @@ main_swapoff(int argc, char *argv[]) {
|
||||||
int status = 0;
|
int status = 0;
|
||||||
int c, i;
|
int c, i;
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "ahvV",
|
while ((c = getopt_long(argc, argv, "ahvVL:U:",
|
||||||
longswapoffopts, NULL)) != -1) {
|
longswapoffopts, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a': /* all */
|
case 'a': /* all */
|
||||||
|
@ -356,8 +446,14 @@ main_swapoff(int argc, char *argv[]) {
|
||||||
++verbose;
|
++verbose;
|
||||||
break;
|
break;
|
||||||
case 'V': /* version */
|
case 'V': /* version */
|
||||||
printf("%s: %s\n", program_name, version);
|
printf("%s: %s\n", progname, version);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
case 'L':
|
||||||
|
addl(optarg);
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
addu(optarg);
|
||||||
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
|
@ -367,13 +463,19 @@ main_swapoff(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (!all && *argv == NULL)
|
if (!all && !llct && !ulct && *argv == NULL)
|
||||||
swapoff_usage(stderr, 2);
|
swapoff_usage(stderr, 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* swapoff any explicitly given arguments.
|
* swapoff any explicitly given arguments.
|
||||||
* Complain in case the swapoff call fails.
|
* Complain in case the swapoff call fails.
|
||||||
*/
|
*/
|
||||||
|
for (i = 0; i < llct; i++)
|
||||||
|
status |= swapoff_by_label(llist[i], !QUIET);
|
||||||
|
|
||||||
|
for (i = 0; i < ulct; i++)
|
||||||
|
status |= swapoff_by_uuid(ulist[i], !QUIET);
|
||||||
|
|
||||||
while (*argv != NULL)
|
while (*argv != NULL)
|
||||||
status |= do_swapoff(*argv++, !QUIET);
|
status |= do_swapoff(*argv++, !QUIET);
|
||||||
|
|
||||||
|
@ -398,7 +500,7 @@ main_swapoff(int argc, char *argv[]) {
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
int errsv = errno;
|
int errsv = errno;
|
||||||
fprintf(stderr, _("%s: cannot open %s: %s\n"),
|
fprintf(stderr, _("%s: cannot open %s: %s\n"),
|
||||||
program_name, _PATH_FSTAB, strerror(errsv));
|
progname, _PATH_FSTAB, strerror(errsv));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
while ((fstab = getmntent(fp)) != NULL) {
|
while ((fstab = getmntent(fp)) != NULL) {
|
||||||
|
@ -420,12 +522,12 @@ main(int argc, char *argv[]) {
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
|
||||||
program_name = argv[0];
|
progname = argv[0];
|
||||||
p = strrchr(program_name, '/');
|
p = strrchr(progname, '/');
|
||||||
if (p)
|
if (p)
|
||||||
program_name = p+1;
|
progname = p+1;
|
||||||
|
|
||||||
if (streq(program_name, "swapon"))
|
if (streq(progname, "swapon"))
|
||||||
return main_swapon(argc, argv);
|
return main_swapon(argc, argv);
|
||||||
else
|
else
|
||||||
return main_swapoff(argc, argv);
|
return main_swapoff(argc, argv);
|
||||||
|
|
|
@ -571,7 +571,10 @@ umount_file (char *arg) {
|
||||||
die(2,
|
die(2,
|
||||||
_("umount: %s is not mounted (according to mtab)"),
|
_("umount: %s is not mounted (according to mtab)"),
|
||||||
file);
|
file);
|
||||||
if (!is_mounted_once(file))
|
/* The 2.4 kernel will generally refuse to mount the same
|
||||||
|
filesystem on the same mount point, but will accept NFS.
|
||||||
|
So, unmounting must be possible. */
|
||||||
|
if (!is_mounted_once(file) && strcmp(mc->m.mnt_type,"nfs"))
|
||||||
die(2,
|
die(2,
|
||||||
_("umount: it seems %s is mounted multiple times"),
|
_("umount: it seems %s is mounted multiple times"),
|
||||||
file);
|
file);
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h> /* strdup() */
|
||||||
|
#include "xmalloc.h"
|
||||||
|
#include "nls.h" /* _() */
|
||||||
|
#include "sundries.h" /* EX_SYSERR */
|
||||||
|
|
||||||
|
void (*at_die)(void) = NULL;
|
||||||
|
|
||||||
|
/* Fatal error. Print message and exit. */
|
||||||
|
void
|
||||||
|
die(int err, const char *fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
vfprintf(stderr, fmt, args);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
if (at_die)
|
||||||
|
(*at_die)();
|
||||||
|
|
||||||
|
exit(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
die_if_null(void *t) {
|
||||||
|
if (t == NULL)
|
||||||
|
die(EX_SYSERR, _("not enough memory"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
xmalloc (size_t size) {
|
||||||
|
void *t;
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
t = malloc(size);
|
||||||
|
die_if_null(t);
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
xrealloc (void *p, size_t size) {
|
||||||
|
void *t;
|
||||||
|
|
||||||
|
t = realloc(p, size);
|
||||||
|
die_if_null(t);
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
xstrdup (const char *s) {
|
||||||
|
char *t;
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
t = strdup(s);
|
||||||
|
die_if_null(t);
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
extern void *xmalloc(size_t size);
|
||||||
|
extern void *xrealloc(void *p, size_t size);
|
||||||
|
extern char *xstrdup(const char *s);
|
||||||
|
extern void die(int err, const char *fmt, ...);
|
||||||
|
extern void (*at_die)(void);
|
1296
po/pt_BR.po
1296
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
|
@ -110,7 +110,11 @@ current IRQ, is implied.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-T [on|off]
|
.B \-T [on|off]
|
||||||
This option tell the lp driver to trust or not the IRQ.
|
This option is obsolete. It was added in Linux 2.1.131,
|
||||||
|
and removed again in Linux 2.3.10. The below is for these
|
||||||
|
old kernels only.
|
||||||
|
|
||||||
|
This option tells the lp driver to trust or not the IRQ.
|
||||||
This option makes sense only if you are using interrupts.
|
This option makes sense only if you are using interrupts.
|
||||||
If you tell the lp driver to trust the irq, then, when the lp driver will
|
If you tell the lp driver to trust the irq, then, when the lp driver will
|
||||||
get an irq, it will send the next pending character to the printer
|
get an irq, it will send the next pending character to the printer
|
||||||
|
|
Loading…
Reference in New Issue