From: rpeterso@sourceware.org <rpeterso@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/gfs2/mkfs Makefile main_mkfs.c
Date: 27 Jun 2006 21:04:18 -0000 [thread overview]
Message-ID: <20060627210418.5782.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2006-06-27 21:04:15
Modified files:
gfs2/mkfs : Makefile main_mkfs.c
Log message:
Switch to libvolume_id method of determining pre-existing file
systems.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mkfs/Makefile.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mkfs/main_mkfs.c.diff?cvsroot=cluster&r1=1.6&r2=1.7
--- cluster/gfs2/mkfs/Makefile 2006/06/09 22:13:19 1.8
+++ cluster/gfs2/mkfs/Makefile 2006/06/27 21:04:13 1.9
@@ -9,18 +9,14 @@
MKFS=mkfs.gfs2
INSTALLPATH=/sbin
-INCLUDEPATH=-I${KERNEL_SRC}/include/ -I${top_srcdir}/include/ -I${top_srcdir}/libgfs2/ -I${top_srcdir}/config/
-#When udev's libvolume_id gets gfs and gfs2 incorporated:
-#INCLUDEPATH=$INCLUDEPATH -I${top_srcdir}/libvolume_id
+INCLUDEPATH=-I${KERNEL_SRC}/include/ -I${top_srcdir}/include/ -I${top_srcdir}/libgfs2/ -I${top_srcdir}/config/
INSTALL=install
CC=gcc -c
LD=gcc
CFLAGS=-Wall -O2 -ggdb -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE \
-D_GNU_SOURCE -DGFS2_RELEASE_NAME=\"2\" ${INCLUDEPATH}
-LDFLAGS=-L${top_srcdir}/libgfs2
-#When udev's libvolume_id gets gfs and gfs2 incorporated:
-#LDFLAGS=$LDFLAGS -L${top_srcdir}/libvolume_id -static
+LDFLAGS=-L${top_srcdir}/libgfs2 -L${libdir}
H=gfs2_disk_hash.h gfs2_mkfs.h linux_endian.h ondisk.h osi_list.h
C=main.c main_mkfs.c
@@ -29,9 +25,7 @@
all: ${MKFS}
${MKFS}: ${O}
- ${LD} ${LDFLAGS} ${O} -o ${@} -lgfs2
-#When udev's libvolume_id gets gfs and gfs2 incorporated add:
-#-lvolume_id
+ ${LD} ${LDFLAGS} ${O} -o ${@} -lgfs2 -lvolume_id
.c.o: $<
${CC} ${CFLAGS} -o $@ $^
--- cluster/gfs2/mkfs/main_mkfs.c 2006/06/06 14:30:55 1.6
+++ cluster/gfs2/mkfs/main_mkfs.c 2006/06/27 21:04:13 1.7
@@ -27,274 +27,7 @@
#include <linux/types.h>
#include "gfs2_mkfs.h"
#include "libgfs2.h"
-#ifdef VOLUME_ID
#include "libvolume_id.h"
-#else
-/* ========================================================================= */
-/* */
-/* */
-/* */
-/* */
-/* */
-/* */
-/* NOTICE: Rip all this out once udev's libvolume_id is shipped as a */
-/* standard library we can link against. */
-/* */
-/* */
-/* */
-/* */
-/* */
-/* */
-/* ========================================================================= */
-#define VOLUME_ID_LABEL_SIZE 64
-#define VOLUME_ID_UUID_SIZE 36
-#define VOLUME_ID_FORMAT_SIZE 32
-#define VOLUME_ID_PATH_MAX 256
-#define VOLUME_ID_PARTITIONS_MAX 256
-#define SB_BUFFER_SIZE 0x11000
-#define SEEK_BUFFER_SIZE 0x10000
-
-#define GFS_MAGIC 0x01161970
-#define GFS_DEFAULT_BSIZE 4096
-#define GFS_SUPERBLOCK_OFFSET (0x10 * GFS_DEFAULT_BSIZE)
-#define GFS_METATYPE_SB 1
-#define GFS_FORMAT_SB 100
-#define GFS_LOCKNAME_LEN 64
-
-/* gfs1 constants: */
-#define GFS_FORMAT_FS 1309
-#define GFS_FORMAT_MULTI 1401
-
-enum volume_id_usage {
- VOLUME_ID_UNUSED,
- VOLUME_ID_UNPROBED,
- VOLUME_ID_OTHER,
- VOLUME_ID_FILESYSTEM,
- VOLUME_ID_RAID,
- VOLUME_ID_DISKLABEL,
- VOLUME_ID_CRYPTO,
-};
-
-struct volume_id {
- uint8_t label_raw[VOLUME_ID_LABEL_SIZE];
- size_t label_raw_len;
- char label[VOLUME_ID_LABEL_SIZE+1];
- uint8_t uuid_raw[VOLUME_ID_UUID_SIZE];
- size_t uuid_raw_len;
- char uuid[VOLUME_ID_UUID_SIZE+1];
- enum volume_id_usage usage_id;
- char *usage;
- char *type;
- char type_version[VOLUME_ID_FORMAT_SIZE];
-
- int fd;
- uint8_t *sbbuf;
- size_t sbbuf_len;
- uint8_t *seekbuf;
- uint64_t seekbuf_off;
- size_t seekbuf_len;
- int fd_close:1;
-};
-
-uint8_t *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
-{
- ssize_t buf_len;
-
- /* check if requested area fits in superblock buffer */
- if (off + len <= SB_BUFFER_SIZE) {
- if (id->sbbuf == NULL) {
- id->sbbuf = malloc(SB_BUFFER_SIZE);
- if (id->sbbuf == NULL) {
- return NULL;
- }
- }
-
- /* check if we need to read */
- if ((off + len) > id->sbbuf_len) {
- if (lseek(id->fd, 0, SEEK_SET) < 0) {
- return NULL;
- }
- buf_len = read(id->fd, id->sbbuf, off + len);
- if (buf_len < 0) {
- return NULL;
- }
- id->sbbuf_len = buf_len;
- if ((size_t)buf_len < off + len) {
- return NULL;
- }
- }
-
- return &(id->sbbuf[off]);
- } else {
- if (len > SEEK_BUFFER_SIZE) {
- return NULL;
- }
- /* get seek buffer */
- if (id->seekbuf == NULL) {
- id->seekbuf = malloc(SEEK_BUFFER_SIZE);
- if (id->seekbuf == NULL) {
- return NULL;
- }
- }
-
- /* check if we need to read */
- if ((off < id->seekbuf_off) || ((off + len) > (id->seekbuf_off + id->seekbuf_len))) {
- if (lseek(id->fd, off, SEEK_SET) < 0) {
- return NULL;
- }
- buf_len = read(id->fd, id->seekbuf, len);
- if (buf_len < 0) {
- return NULL;
- }
- id->seekbuf_off = off;
- id->seekbuf_len = buf_len;
- if ((size_t)buf_len < len) {
- return NULL;
- }
- }
-
- return &(id->seekbuf[off - id->seekbuf_off]);
- }
-}
-
-void volume_id_free_buffer(struct volume_id *id)
-{
- if (id->sbbuf != NULL) {
- free(id->sbbuf);
- id->sbbuf = NULL;
- id->sbbuf_len = 0;
- }
- if (id->seekbuf != NULL) {
- free(id->seekbuf);
- id->seekbuf = NULL;
- id->seekbuf_len = 0;
- }
-}
-
-static char *usage_to_string(enum volume_id_usage usage_id)
-{
- switch (usage_id) {
- case VOLUME_ID_FILESYSTEM:
- return "filesystem";
- case VOLUME_ID_OTHER:
- return "other";
- case VOLUME_ID_RAID:
- return "raid";
- case VOLUME_ID_DISKLABEL:
- return "disklabel";
- case VOLUME_ID_CRYPTO:
- return "crypto";
- case VOLUME_ID_UNPROBED:
- return "unprobed";
- case VOLUME_ID_UNUSED:
- return "unused";
- }
- return NULL;
-}
-
-void volume_id_set_usage(struct volume_id *id, enum volume_id_usage usage_id)
-{
- id->usage_id = usage_id;
- id->usage = usage_to_string(usage_id);
-}
-
-int volume_id_probe_gfs_generic(struct volume_id *id, uint64_t off, int vers)
-{
- struct gfs2_sb *sbd;
-
- sbd = (struct gfs2_sb *) volume_id_get_buffer(id,
- off + GFS_SUPERBLOCK_OFFSET,
- sizeof(struct gfs2_sb));
- if (sbd == NULL)
- return -1;
-
- if (be32_to_cpu(sbd->sb_header.mh_magic) == GFS_MAGIC &&
- be32_to_cpu(sbd->sb_header.mh_type) == GFS_METATYPE_SB &&
- be32_to_cpu(sbd->sb_header.mh_format) == GFS_FORMAT_SB) {
- if (vers == 1) {
- if (be32_to_cpu(sbd->sb_fs_format) != GFS_FORMAT_FS ||
- be32_to_cpu(sbd->sb_multihost_format) != GFS_FORMAT_MULTI)
- return -1; /* not gfs1 */
- id->type = "gfs";
- }
- else if (vers == 2) {
- if (be32_to_cpu(sbd->sb_fs_format) != GFS2_FORMAT_FS ||
- be32_to_cpu(sbd->sb_multihost_format) != GFS2_FORMAT_MULTI)
- return -1; /* not gfs2 */
- id->type = "gfs2";
- }
- else
- return -1;
- strcpy(id->type_version, "1");
- volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
- return 0;
- }
- return -1;
-}
-
-int volume_id_probe_gfs(struct volume_id *id, uint64_t off)
-{
- return (volume_id_probe_gfs_generic(id, off, 1));
-}
-
-int volume_id_probe_gfs2(struct volume_id *id, uint64_t off)
-{
- return (volume_id_probe_gfs_generic(id, off, 2));
-}
-
-/* open volume by already open file descriptor */
-struct volume_id *volume_id_open_fd(int fd)
-{
- struct volume_id *id;
-
- id = malloc(sizeof(struct volume_id));
- if (id == NULL)
- return NULL;
- memset(id, 0x00, sizeof(struct volume_id));
-
- id->fd = fd;
-
- return id;
-}
-
-struct volume_id *volume_id_open_node(const char *path)
-{
- struct volume_id *id;
- int fd;
-
- fd = open(path, O_RDONLY);
- if (fd < 0) {
- return NULL;
- }
- id = volume_id_open_fd(fd);
- if (id == NULL)
- return NULL;
-
- /* close fd on device close */
- id->fd_close = 1;
- return id;
-}
-
-int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)
-{
- volume_id_get_buffer(id, 0, SB_BUFFER_SIZE);
- if (volume_id_probe_gfs2(id, off) == 0) {
- volume_id_free_buffer(id);
- return 0;
- }
- return -1;
-}
-
-void volume_id_close(struct volume_id *id)
-{
- if (id == NULL)
- return;
- if (id->fd_close != 0)
- close(id->fd);
- volume_id_free_buffer(id);
- free(id);
-}
-#endif
char *prog_name;
reply other threads:[~2006-06-27 21:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060627210418.5782.qmail@sourceware.org \
--to=rpeterso@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.