Hi Jason, good idea, but I have a few notes: On Thu, Mar 04, 2010 at 12:29:51PM -0700, Jason Borden wrote: > > This patch adds a new program to the project which is analogous to e2label > but for swap partitions. The reason behind having this program is to allow it would be nice to use the same tool for UUID changes. > +#include <stdio.h> > +#include <string.h> > +#include <fcntl.h> > +#include <sys/types.h> > +#include <sys/stat.h> > +#include <unistd.h> > +#include <stdlib.h> > +#include <stdarg.h> > +#include <errno.h> > +#include "nls.h" > + > +#define SWAP_MAGIC_OFFSET 0xFF6 The position of the magic string depends on the page size, there is five offsets where you can found the magic (0xff6, 0x1ff6, 0x3ff6, 0x7ff6 and 0xfff6). The ideal solution is use libblkid to check that the device really contains a swap. See shlibs/blkid/samples/superblocks.c. The libblkid also returns LABEL and UUID from the device. > +#define SWAP_MAGIC_VALUE "SWAPSPACE2" > +#define SWAP_MAGIC_LENGTH 10 > + > +#define SWAP_LABEL_OFFSET 0x41C > +#define SWAP_LABEL_LENGTH 16 > + > +/* A function to print errors and exit */ > +static void perror_exit(const char *perrorstr, int exitcode, const char > *stder > rstr, ...) > +{ > + va_list ap; > + > + if (perrorstr) > + perror(perrorstr); > + va_start(ap, stderrstr); > + vfprintf(stderr, stderrstr, ap); > + va_end(ap); > + exit(exitcode); > +} #include <err.h> and use errx() and err(). Karel -- Karel Zak <kzak@xxxxxxxxxx> -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html