All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/gfs/libgfs Makefile libgfs.h size.c gf ...
@ 2006-07-10 23:28 rpeterso
  0 siblings, 0 replies; only message in thread
From: rpeterso @ 2006-07-10 23:28 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rpeterso at sourceware.org	2006-07-10 23:28:11

Modified files:
	gfs/libgfs     : Makefile libgfs.h 
Added files:
	gfs/libgfs     : size.c 
Removed files:
	gfs/libgfs     : gfs_ondisk.h missing 

Log message:
	Changes necessary due to removal of iddev parts (replaced by libvolume_id)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/libgfs/size.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/libgfs/Makefile.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/libgfs/libgfs.h.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/libgfs/gfs_ondisk.h.diff?cvsroot=cluster&r1=1.1&r2=NONE
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs/libgfs/missing.diff?cvsroot=cluster&r1=1.1&r2=NONE

/cvs/cluster/cluster/gfs/libgfs/size.c,v  -->  standard output
revision 1.1
--- cluster/gfs/libgfs/size.c
+++ -	2006-07-10 23:28:11.582177000 +0000
@@ -0,0 +1,94 @@
+/******************************************************************************
+*******************************************************************************
+**
+**  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
+**  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+**  
+**  This copyrighted material is made available to anyone wishing to use,
+**  modify, copy, or redistribute it subject to the terms and conditions
+**  of the GNU General Public License v.2.
+**
+*******************************************************************************
+******************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mount.h>
+
+#include "libgfs.h"
+
+#ifndef BLKGETSIZE64
+#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
+#endif
+
+/**
+ * do_device_size - determine the size of a Linux block device
+ * @device: the path to the device node
+ *
+ * Returns: -1 on error (with errno set), 0 on success (with @bytes set)
+ */
+
+static int
+do_device_size(int fd, uint64_t *bytes)
+{
+	unsigned long size;
+	off_t off;
+	int error;
+
+	error = ioctl(fd, BLKGETSIZE64, bytes);	/* Size in bytes */
+	if (!error)
+		return 0;
+
+	error = ioctl(fd, BLKGETSIZE, &size);	/* Size in 512-byte blocks */
+	if (!error) {
+		*bytes = ((uint64_t) size) << 9;
+		return 0;
+	}
+
+	off = lseek(fd, 0, SEEK_END);
+	if (off >= 0) {
+		*bytes = off;
+		return 0;
+	}
+
+	return -1;
+}
+
+/**
+ * device_size - figure out a device's size
+ * @fd: the file descriptor of a device
+ * @bytes: the number of bytes the device holds
+ *
+ * Returns: -1 on error (with errno set), 0 on success (with @bytes set)
+ */
+
+int
+device_size(int fd, uint64_t *bytes)
+{
+	struct stat st;
+	int error;
+
+	error = fstat(fd, &st);
+	if (error)
+		return error;
+
+	if (S_ISREG(st.st_mode)) {
+		*bytes = st.st_size;
+		return 0;
+	} else if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))
+		return do_device_size(fd, bytes);
+	else if (S_ISDIR(st.st_mode))
+		errno = EISDIR;
+	else
+		errno = EINVAL;
+
+	return -1;
+}
--- cluster/gfs/libgfs/Makefile	2006/05/15 18:56:07	1.1
+++ cluster/gfs/libgfs/Makefile	2006/07/10 23:28:11	1.2
@@ -17,7 +17,7 @@
 include ${top_srcdir}/make/defines.mk
 
 LIBGFS=libgfs.a
-INCLUDEPATH=-I${top_srcdir}/include -I${top_srcdir}/config -I${KERNEL_SRC}/fs/gfs2/ -I${KERNEL_SRC}/include/
+INCLUDEPATH=-I${top_srcdir}/include -I${top_srcdir}/config -I${KERNEL_SRC}/fs/gfs2/ -I${KERNEL_SRC}/include/ -I${gfskincdir}
 
 INSTALL=install
 CC=gcc -c
@@ -27,7 +27,7 @@
 
 H=gfs_ondisk.h incore.h libgfs.h
 C=bio.c bitmap.c block_list.c file.c fs_bits.c fs_bmap.c fs_dir.c \
-	fs_inode.c inode.c log.c ondisk.c rgrp.c super.c util.c
+	fs_inode.c inode.c log.c ondisk.c rgrp.c size.c super.c util.c
 O=$(subst .c,.o,${C})
 
 all: ${LIBGFS}
--- cluster/gfs/libgfs/libgfs.h	2006/05/15 18:56:07	1.1
+++ cluster/gfs/libgfs/libgfs.h	2006/07/10 23:28:11	1.2
@@ -260,6 +260,11 @@
 		 uint64 *dblock, uint32 *extlen);
 
 /* ------------------------------------------------------------------------- */
+/* formerly iddev.h                                                          */
+/* ------------------------------------------------------------------------- */
+int device_size(int fd, uint64_t *bytes);
+
+/* ------------------------------------------------------------------------- */
 /* formerly util.h:                                                          */
 /* ------------------------------------------------------------------------- */
 #define do_lseek(fd, off) \
@@ -328,7 +333,6 @@
 int fs_copyin_dinode(int disk_fd, uint32_t sb_bsize, struct gfs_inode *ip, osi_buf_t *bh);
 int fs_copyout_dinode(int disk_fd, uint32_t sb_bsize, struct gfs_inode *ip);
 int fs_mkdir(int disk_fd, struct gfs_inode *dip, char *new_dir, int mode, struct gfs_inode **nip);
-int fs_remove(struct gfs_inode *ip);
 
 static __inline__ int fs_is_stuffed(struct gfs_inode *ip)
 {



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-07-10 23:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-10 23:28 [Cluster-devel] cluster/gfs/libgfs Makefile libgfs.h size.c gf rpeterso

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.