Re-add FreeBSD support.

Tested on FreeBSD 5.2-CURRENT as of 2003-12-28.
Tested on FreeBSD 4.9-STABLE  as of 2003-12-27.
bitmap-optimize
Matthias Andree 2003-12-28 18:21:26 +01:00
parent b969b1b8a5
commit b34cbddbd6
7 changed files with 47 additions and 9 deletions

View File

@ -569,7 +569,7 @@ if test $cross_compiling = no; then
else else
AC_CHECK_PROGS(BUILD_CC, gcc cc) AC_CHECK_PROGS(BUILD_CC, gcc cc)
fi fi
AC_CHECK_HEADERS(stdlib.h unistd.h stdarg.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if.h netinet/in.h) AC_CHECK_HEADERS(stdlib.h unistd.h stdarg.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disk.h sys/disklabel.h sys/ioctl.h sys/mkdev.h sys/mount.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if.h netinet/in.h)
AC_FUNC_VPRINTF AC_FUNC_VPRINTF
dnl Check to see if dirent has member d_reclen. On cygwin those d_reclen dnl Check to see if dirent has member d_reclen. On cygwin those d_reclen
dnl is not decleared. dnl is not decleared.

View File

@ -13,6 +13,7 @@
*/ */
#ifdef HAVE_SYS_MOUNT_H #ifdef HAVE_SYS_MOUNT_H
#include <sys/param.h>
#include <sys/mount.h> #include <sys/mount.h>
#define MNT_FL (MS_MGC_VAL | MS_RDONLY) #define MNT_FL (MS_MGC_VAL | MS_RDONLY)
#endif #endif

View File

@ -21,6 +21,7 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif #endif
#if HAVE_SYS_MOUNT_H #if HAVE_SYS_MOUNT_H
#include <sys/param.h>
#include <sys/mount.h> /* This may define BLKFLSBUF */ #include <sys/mount.h> /* This may define BLKFLSBUF */
#endif #endif

View File

@ -28,9 +28,14 @@
#include <linux/fd.h> #include <linux/fd.h>
#endif #endif
#ifdef HAVE_SYS_DISKLABEL_H #ifdef HAVE_SYS_DISKLABEL_H
#include <sys/param.h> /* for __FreeBSD_version */
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/disklabel.h> #include <sys/disklabel.h>
#endif /* HAVE_SYS_DISKLABEL_H */ #endif /* HAVE_SYS_DISKLABEL_H */
#ifdef HAVE_SYS_DISK_H
#include <sys/queue.h> /* for LIST_HEAD */
#include <sys/disk.h>
#endif /* HAVE_SYS_DISK_H */
#if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE) #if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE)
#define BLKGETSIZE _IO(0x12,96) /* return device size */ #define BLKGETSIZE _IO(0x12,96) /* return device size */
@ -147,6 +152,8 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
} }
#endif #endif
#ifdef HAVE_SYS_DISKLABEL_H #ifdef HAVE_SYS_DISKLABEL_H
#if defined(__FreeBSD__) && __FreeBSD_version < 500040
/* old disklabel interface */
part = strlen(file) - 1; part = strlen(file) - 1;
if (part >= 0) { if (part >= 0) {
ch = file[part]; ch = file[part];
@ -165,6 +172,16 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
return 0; return 0;
} }
} }
#else /* __FreeBSD_version < 500040 */
{
off_t ms;
u_int bs;
if (ioctl(fd, DIOCGMEDIASIZE, &ms) >= 0) {
*retblocks = ms / blocksize;
return 0;
}
}
#endif /* __FreeBSD_version < 500040 */
#endif /* HAVE_SYS_DISKLABEL_H */ #endif /* HAVE_SYS_DISKLABEL_H */
/* /*

View File

@ -85,6 +85,12 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset,
static void reuse_cache(io_channel channel, struct unix_private_data *data, static void reuse_cache(io_channel channel, struct unix_private_data *data,
struct unix_cache *cache, unsigned long block); struct unix_cache *cache, unsigned long block);
#if defined(__CYGWIN__) || defined(__FreeBSD__)
#define NEED_BOUNCE_BUFFER
#else
#undef NEED_BOUNCE_BUFFER
#endif
static struct struct_io_manager struct_unix_manager = { static struct struct_io_manager struct_unix_manager = {
EXT2_ET_MAGIC_IO_MANAGER, EXT2_ET_MAGIC_IO_MANAGER,
"Unix I/O Manager", "Unix I/O Manager",
@ -94,7 +100,7 @@ static struct struct_io_manager struct_unix_manager = {
unix_read_blk, unix_read_blk,
unix_write_blk, unix_write_blk,
unix_flush, unix_flush,
#ifdef __CYGWIN__ #ifdef NEED_BOUNCE_BUFFER
0 0
#else #else
unix_write_byte unix_write_byte
@ -106,7 +112,7 @@ io_manager unix_io_manager = &struct_unix_manager;
/* /*
* Here are the raw I/O functions * Here are the raw I/O functions
*/ */
#ifndef __CYGWIN__ #ifndef NEED_BOUNCE_BUFFER
static errcode_t raw_read_blk(io_channel channel, static errcode_t raw_read_blk(io_channel channel,
struct unix_private_data *data, struct unix_private_data *data,
unsigned long block, unsigned long block,
@ -139,9 +145,9 @@ error_out:
size, actual, retval); size, actual, retval);
return retval; return retval;
} }
#else /* __CYGWIN__ */ #else /* NEED_BOUNCE_BUFFER */
/* /*
* Windows block devices only allow sector alignment IO in offset and size * Windows and FreeBSD block devices only allow sector alignment IO in offset and size
*/ */
static errcode_t raw_read_blk(io_channel channel, static errcode_t raw_read_blk(io_channel channel,
struct unix_private_data *data, struct unix_private_data *data,

View File

@ -9,6 +9,15 @@
* %End-Header% * %End-Header%
*/ */
#ifndef __LINUX__
#include <stdio.h>
#include <stdlib.h>
int main(void) {
fputs("This program is only supported on Linux!\n", stderr);
exit(EXIT_FAILURE);
}
#else
#define _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE
#include <stdio.h> #include <stdio.h>
@ -158,6 +167,4 @@ int main(int argc, char**argv)
} }
return 0; return 0;
} }
#endif

View File

@ -97,7 +97,13 @@ void check_plausibility(const char *device)
"did you specify it correctly?\n"), stderr); "did you specify it correctly?\n"), stderr);
exit(1); exit(1);
} }
if (!S_ISBLK(s.st_mode)) { #ifdef __FreeBSD__
/* On FreeBSD, all disk devices are character specials */
if (!S_ISBLK(s.st_mode) && !S_ISCHR(s.st_mode))
#else
if (!S_ISBLK(s.st_mode))
#endif
{
printf(_("%s is not a block special device.\n"), device); printf(_("%s is not a block special device.\n"), device);
proceed_question(); proceed_question();
return; return;