Add support for DragonFly BSD operating system.
PATCH 1/1 Add support for DragonFly BSD operating system.
Hi,
Find below a patch to add support for DragonFly BSD to e2fsprogs. In the case it gets rejected please indicate a reason so I can get it fixed.
For convenience I've uploaded the patch here: http://island.quantumachine.net/~antonioh/archive/patches/0001-Add-support-for-DragonFly-BSD-operating-system.patch
Regards,
Antonio Huete
From 31838ebfd8dd6a52a98ca083fb20401db82e6398 Mon Sep 17 00:00:00 2001
From: Antonio Huete Jimenez <[email protected]>
Date: Thu, 12 Jul 2012 21:33:57 +0200
Subject: [PATCH] Add support for DragonFly BSD operating system.
- Add a new OS tag.
- DragonFly uses DIOCGPART to return disk information.
- Avoid falling to some old FreeBSD 4.x code blocks.
--- lib/blkid/getsize.c | 15 ++++++++++++++- lib/e2p/ostype.c | 5 +++-- lib/ext2fs/ext2_fs.h | 1 + lib/ext2fs/getsize.c | 13 +++++++++++++ lib/ext2fs/initialize.c | 4 ++++ lib/ext2fs/unix_io.c | 2 +- misc/mke2fs.c | 2 ++ misc/util.c | 2 +- 8 files changed, 39 insertions(+), 5 deletions(-)
lib/blkid/getsize.c +14 -1
@@ -45,7 +45,9 @@#if HAVE_SYS_STAT_H #include <sys/stat.h> #endif - +#ifdef __DragonFly__ +#include <sys/diskslice.h> +#endif #if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE )#define BLKGETSIZE _IO(0x12,96)/* return device size */
@@ -87,8 +89,10 @@ blkid_loff_t blkid_get_dev_size(int fd)#endif #ifdef HAVE_SYS_DISKLABEL_H int part =-1 ; +#ifndef __DragonFly__struct disklabel lab;struct partition *pp; +#endif /* __DragonFly__ */ char ch;struct stat st;#endif /* HAVE_SYS_DISKLABEL_H */
@@ -129,11 +133,19 @@ blkid_loff_t blkid_get_dev_size(int fd)return (off_t )size64;#endif /* DIOCGMEDIASIZE */ +/* tested on DragonFly 3.1-DEVELOPMENT i386/X86_64 */ +#ifdef DIOCGPART +struct partinfo dp; +if (ioctl (fd,DIOCGPART , &dp) >=0 ) +return (off_t )dp.media_size; +#endif /* DIOCGPART */ +#ifdef FDGETPRM if (ioctl (fd,FDGETPRM , &this_floppy) >=0 )return (blkid_loff_t )this_floppy.size <<9 ;#endif #ifdef HAVE_SYS_DISKLABEL_H +#ifndef __DragonFly__/* * This code works for FreeBSD 4.11 i386, except for the full device * (such as /dev/ad0). It doesn't work properly for newer FreeBSD
@@ -151,6 +163,7 @@ blkid_loff_t blkid_get_dev_size(int fd)if (pp->p_size) return pp->p_size << 9; } +#endif / __DragonFly__ */ #endif /* HAVE_SYS_DISKLABEL_H */ {#if defined(HAVE_FSTAT64 ) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
lib/e2p/ostype.c +3 -2
@@ -20,6 +20,7 @@ static const char *os_tab[] ="Masix" ,"FreeBSD" ,"Lites" , +"DragonFly" , 0 };/*
@@ -30,7 +31,7 @@ char *e2p_os2string(int os_type)const char *os;char *ret; -if (os_type <=EXT2_OS_LITES ) +if (os_type <=EXT2_OS_DRAGONFLY ) os = os_tab[os_type];else os ="(unknown os)" ;
@@ -62,7 +63,7 @@ int main(int argc, char **argv)char *s;int i, os; -for (i=0 ; i <=EXT2_OS_LITES ; i++) { +for (i=0 ; i <=EXT2_OS_DRAGONFLY ; i++) { s =e2p_os2string (i); os =e2p_string2os (s);printf ("%d: %s (%d)\n" , i, s, os);
lib/ext2fs/ext2_fs.h +1 -0
@@ -659,6 +659,7 @@ struct ext2_super_block {#define EXT2_OBSO_OS_MASIX 2#define EXT2_OS_FREEBSD 3#define EXT2_OS_LITES 4 +#define EXT2_OS_DRAGONFLY 5/* * Revision levels
lib/ext2fs/getsize.c +13 -0
@@ -46,6 +46,9 @@#include <sys/stat.h> #endif #include <ctype.h> +#ifdef __DragonFly__ +#include <sys/diskslice.h> +#endif #if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE )#define BLKGETSIZE _IO(0x12,96)/* return device size */
@@ -155,8 +158,10 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,#endif #ifdef HAVE_SYS_DISKLABEL_H int part; +#ifndef __DragonFly__struct disklabel lab;struct partition *pp; +#endif /*__DragonFly__ */ char ch;#endif /* HAVE_SYS_DISKLABEL_H */
@@ -228,6 +233,14 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize, goto out; } } +#elif defined(DIOCGPART ) +/* DragonFly partition information */ +struct partinfo dp; +if (ioctl (fd,DIOCGPART , &dp) >=0 ) { + *retblocks = dp.media_size / blocksize; + goto out; + } +#endif /* defined(DIOCG*) */ #endif /* HAVE_SYS_DISKLABEL_H */
lib/ext2fs/initialize.c +4 -0
@@ -40,7 +40,11 @@#if defined(LITES ) && defined(EXT2_OS_LITES )#define CREATOR_OS EXT2_OS_LITES#else +#if defined(__DragonFly__) && defined(EXT2_OS_DRAGONFLY ) +#define CREATOR_OS EXT2_OS_DRAGONFLY +#else #define CREATOR_OS EXT2_OS_LINUX/* by default */ +#endif /* defined(__DragonFly__) && defined(EXT2_OS_DRAGONFLY) */ #endif /* defined(LITES) && defined(EXT2_OS_LITES) */ #endif /* defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD) */ #endif /* defined(__GNU__) && defined(EXT2_OS_HURD) */
lib/ext2fs/unix_io.c +1 -1
@@ -554,7 +554,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) io->flags |=CHANNEL_FLAGS_DISCARD_ZEROES ;#endif -#if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)/* * Some operating systems require that the buffers be aligned, * regardless of O_DIRECT
misc/mke2fs.c +2 -0
@@ -641,6 +641,8 @@ static int set_os(struct ext2_super_block *sb, char *os) sb->s_creator_os =EXT2_OS_FREEBSD ; else if (strcasecmp(os, "lites") == 0) sb->s_creator_os = EXT2_OS_LITES; + else if (strcasecmp(os, "dragonfly") == 0) + sb->s_creator_os = EXT2_OS_DRAGONFLY; else return 0;return 1 ;
misc/util.c +1 -1
@@ -93,7 +93,7 @@ void check_plausibility(const char *device) "did you specify it correctly?\n"), stderr);exit (1 ); } -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)/* On FreeBSD, all disk devices are character specials */ if (!S_ISBLK (s.st_mode) && !S_ISCHR (s.st_mode)) #else
Signature · 1 line
1.7.3.4
lib/blkid/getsize.c blkid_loff_t blkid_get_dev_size(int fd) · line 98
Quoted 12 lines · Antonio Huete Jiménez
Find below a patch to add support for DragonFly BSD to e2fsprogs. In the case it gets rejected please indicate a reason so I can get it fixed.
lib/blkid/getsize.c +2
-0@@ -87,8 +89,10 @@ blkid_loff_t blkid_get_dev_size(int fd)#endif #ifdef HAVE_SYS_DISKLABEL_H int part =-1 ; +#ifndef __DragonFly__struct disklabel lab;struct partition *pp; +#endif /* __DragonFly__ */ char ch;struct stat st;#endif /* HAVE_SYS_DISKLABEL_H */
Hmm, why not #ifndef out the whole HAVE_SYS_DISKLABEL_H block? The "part", "ch", and "st" variables are only used inside HAVE_SYS_DISKLABEL_H below, and it appears that "ch" isn't even used anywhere and could just be removed.
It would be cleaner to move these declarations into a small sub-context at the HAVE_SYS_DISKLABEL_H case (ala HAVE_FSTAT64), since $diety knows this code has too many #ifdefs already and could use some cleanup.
lib/blkid/getsize.c blkid_loff_t blkid_get_dev_size(int fd) · line 141
Quoted 10 lines
lib/blkid/getsize.c +6
-0@@ -129,11 +133,19 @@ blkid_loff_t blkid_get_dev_size(int fd)return (off_t )size64;#endif /* DIOCGMEDIASIZE */ +/* tested on DragonFly 3.1-DEVELOPMENT i386/X86_64 */ +#ifdef DIOCGPART +struct partinfo dp; +if (ioctl (fd,DIOCGPART , &dp) >=0 ) +return (off_t )dp.media_size; +#endif /* DIOCGPART */
While supported by newer C standards, it is atypical to have variable declarations in the middle of the code. Better would be to make this a small sub-context, like is done with HAVE_FSTAT64.
lib/blkid/getsize.c blkid_loff_t blkid_get_dev_size(int fd) · line 148
Quoted 6 lines
lib/blkid/getsize.c +1
-0#ifdef FDGETPRM if (ioctl (fd,FDGETPRM , &this_floppy) >=0 )return (blkid_loff_t )this_floppy.size <<9 ;#endif #ifdef HAVE_SYS_DISKLABEL_H +#ifndef __DragonFly__
Better (IMHO) would be:
#if defined(HAVE_SYS_DISKLABEL_H) && !defined __DragonFly__
Quoted 82 lines
lib/blkid/getsize.c +1
-0/* * This code works for FreeBSD 4.11 i386, except for the full device * (such as /dev/ad0). It doesn't work properly for newer FreeBSD @@ -151,6 +163,7 @@ blkid_loff_t blkid_get_dev_size(int fd)if (pp->p_size) return pp->p_size << 9; } +#endif / __DragonFly__ */ #endif /* HAVE_SYS_DISKLABEL_H */ {#if defined(HAVE_FSTAT64 ) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)lib/e2p/ostype.c +3
-2@@ -20,6 +20,7 @@ static const char *os_tab[] ="Masix" ,"FreeBSD" ,"Lites" , +"DragonFly" , 0 };/* @@ -30,7 +31,7 @@ char *e2p_os2string(int os_type)const char *os;char *ret; -if (os_type <=EXT2_OS_LITES ) +if (os_type <=EXT2_OS_DRAGONFLY ) os = os_tab[os_type];else os ="(unknown os)" ;@@ -62,7 +63,7 @@ int main(int argc, char **argv)char *s;int i, os; -for (i=0 ; i <=EXT2_OS_LITES ; i++) { +for (i=0 ; i <=EXT2_OS_DRAGONFLY ; i++) { s =e2p_os2string (i); os =e2p_string2os (s);printf ("%d: %s (%d)\n" , i, s, os);lib/ext2fs/ext2_fs.h +1
-0@@ -659,6 +659,7 @@ struct ext2_super_block {#define EXT2_OBSO_OS_MASIX 2#define EXT2_OS_FREEBSD 3#define EXT2_OS_LITES 4 +#define EXT2_OS_DRAGONFLY 5/* * Revision levels lib/ext2fs/getsize.c +5
-0@@ -46,6 +46,9 @@#include <sys/stat.h> #endif #include <ctype.h> +#ifdef __DragonFly__ +#include <sys/diskslice.h> +#endif #if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE )#define BLKGETSIZE _IO(0x12,96)/* return device size */ @@ -155,8 +158,10 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,#endif #ifdef HAVE_SYS_DISKLABEL_H int part; +#ifndef __DragonFly__struct disklabel lab;struct partition *pp; +#endif /*__DragonFly__ */ char ch;#endif /* HAVE_SYS_DISKLABEL_H */ @@ -228,6 +233,14 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize, goto out; } }
lib/ext2fs/getsize.c errcode_t ext2fs_get_device_size2(const char *file, int blocksize, · line 245
Quoted 10 lines
lib/ext2fs/getsize.c +8
-0+#elif defined(DIOCGPART ) +/* DragonFly partition information */ +struct partinfo dp; +if (ioctl (fd,DIOCGPART , &dp) >=0 ) { + *retblocks = dp.media_size / blocksize; + goto out; + } +#endif /* defined(DIOCG*) */ #endif /* HAVE_SYS_DISKLABEL_H */
Same comments here. Makes me wonder if we couldn't share this code in
some manner, but they are independent libraries and we didn't want to have blkid depending on e2fsprogs, though the reverse is already true so maybe we should just beef up blkid_get_dev_size() and have ext2fs_get_device_size()
and ext2fs_get_device_size2() be thin wrappers around that function?
I don't think it changes frequently enough that we need to worry about the fact that on Linux the libblkid code is now maintained in util-linux-ng.
Quoted 6 lines
lib/ext2fs/initialize.c +0
-0@@ -40,7 +40,11 @@#if defined(LITES ) && defined(EXT2_OS_LITES )
lib/ext2fs/initialize.c line 50
Quoted 10 lines
lib/ext2fs/initialize.c +4
-0#define CREATOR_OS EXT2_OS_LITES#else +#if defined(__DragonFly__) && defined(EXT2_OS_DRAGONFLY ) +#define CREATOR_OS EXT2_OS_DRAGONFLY +#else #define CREATOR_OS EXT2_OS_LINUX/* by default */ +#endif /* defined(__DragonFly__) && defined(EXT2_OS_DRAGONFLY) */ #endif /* defined(LITES) && defined(EXT2_OS_LITES) */ #endif /* defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD) */ #endif /* defined(__GNU__) && defined(EXT2_OS_HURD) */
Ugh. Existing code uglyness aside, this would be better as an #elif instead of a nested series if #if/#else blocks.
Quoted 45 lines
lib/ext2fs/unix_io.c +1
-1@@ -554,7 +554,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) io->flags |=CHANNEL_FLAGS_DISCARD_ZEROES ;#endif -#if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)/* * Some operating systems require that the buffers be aligned, * regardless of O_DIRECT misc/mke2fs.c +2
-0@@ -641,6 +641,8 @@ static int set_os(struct ext2_super_block *sb, char *os) sb->s_creator_os =EXT2_OS_FREEBSD ; else if (strcasecmp(os, "lites") == 0) sb->s_creator_os = EXT2_OS_LITES; + else if (strcasecmp(os, "dragonfly") == 0) + sb->s_creator_os = EXT2_OS_DRAGONFLY; else return 0;return 1 ;misc/util.c +1
-1@@ -93,7 +93,7 @@ void check_plausibility(const char *device) "did you specify it correctly?\n"), stderr);exit (1 ); } -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)/* On FreeBSD, all disk devices are character specials */ if (!S_ISBLK (s.st_mode) && !S_ISCHR (s.st_mode)) #elseSignature · 5 lines
1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers, Andreas
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Antonio Huete Jiménez
- Add a new OS tag.
Is there a particular reason why you need the OS tag? That's really more of a historical thing than anything else. I'd be much happier renaming the FreeBSD tag to BSD.
The only thing where we change what we do based on the OS tag was for the Hurd operating system, and I consider what was done back then by Remy Card (one of the original ext2 authors) to be a design mistake.
Also, for future reference, it's highly preferable to have separate patches for each logically distinct change; it's easier to review, especially if it's only one patch out of several that needs to be modified/reworked.
Regards,
- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello Theodore, Andreas,
Thanks for taking the time to review the patch. I've split the patch in two parts.
- First one to change the tag as recommended by Theodore. There is not specific reason for wanting a tag for DragonFly so I also think the idea of a 'BSD' tag is nicer. The rest of main BSDs are included now. I've also untangled the #ifdef #else's and converted it to a shorter block using #elif, as specified by Andreas.
- Second patch fixes the issues I consider necessary for DragonFly BSD to be able to format disk/slices in ext2/3/4 format. Andreas, I've followed the recommendation of using less #ifdefs, you will see that patch is cleaner now. With regards to merging both libraries (ext2fs and blkid) I am afraid I have not much time for doing it, sorry.
I've pasted both new patches in this email with the intention of producing less traffic in the mailing list, but I'm unsure if this is the correct thing to do, opposed to sending one mail per patch.
If there is anything wrong, just let me know and I'll try to correct it.
Best regards,
Antonio Huete
From 66c7097eaf08fd9c0e2453fb35c2e95939e3303b Mon Sep 17 00:00:00 2001
From: Antonio Huete Jimenez <[email protected]>
Date: Mon, 16 Jul 2012 00:50:50 +0200
Subject: [PATCH 1/2] Common BSD tag for FreeBSD, NetBSD, OpenBSD and DragonFly BSD.
- All BSD will appear now as "BSD" under the OS creator field.
- Minor adjustments to multiple #if's
--- lib/e2p/ostype.c | 2 +- lib/ext2fs/ext2_fs.h | 2 +- lib/ext2fs/initialize.c | 19 ++++++------------- misc/mke2fs.c | 8 +++++++- 4 files changed, 15 insertions(+), 16 deletions(-)
lib/e2p/ostype.c +1 -1
@@ -18,7 +18,7 @@ static const char *os_tab[] = {"Linux" ,"Hurd" ,"Masix" , -"FreeBSD" , +"BSD" ,"Lites" , 0 };
lib/ext2fs/ext2_fs.h +1 -1
@@ -657,7 +657,7 @@ struct ext2_super_block {#define EXT2_OS_LINUX 0#define EXT2_OS_HURD 1#define EXT2_OBSO_OS_MASIX 2 -#define EXT2_OS_FREEBSD 3 +#define EXT2_OS_BSD 3#define EXT2_OS_LITES 4/*
lib/ext2fs/initialize.c +6 -13
@@ -28,23 +28,16 @@#include "ext2_fs.h" #include "ext2fs.h" -#if defined(__linux__) && defined(EXT2_OS_LINUX ) -#define CREATOR_OS EXT2_OS_LINUX -#else -#if defined(__GNU__) && defined(EXT2_OS_HURD ) +#if defined(__GNU__) && defined(EXT2_OS_HURD )#define CREATOR_OS EXT2_OS_HURD -#else -#if defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD ) -#define CREATOR_OS EXT2_OS_FREEBSD -#else -#if defined(LITES ) && defined(EXT2_OS_LITES ) +#elif (defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) \ + || defined(__DragonFly__)) && defined(EXT2_OS_BSD ) +#define CREATOR_OS EXT2_OS_BSD +#elif defined(LITES ) && defined(EXT2_OS_LITES )#define CREATOR_OS EXT2_OS_LITES#else #define CREATOR_OS EXT2_OS_LINUX/* by default */ -#endif /* defined(LITES) && defined(EXT2_OS_LITES) */ -#endif /* defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD) */ -#endif /* defined(__GNU__) && defined(EXT2_OS_HURD) */ -#endif /* defined(__linux__) && defined(EXT2_OS_LINUX) */ +#endif /* * Calculate the number of GDT blocks to reserve for online filesystem
growth.
misc/mke2fs.c +7 -1
@@ -638,7 +638,13 @@ static int set_os(struct ext2_super_block *sb, char *os)else if (strcasecmp (os,"GNU" ) ==0 ||strcasecmp (os,"hurd" ) ==0 ) sb->s_creator_os =EXT2_OS_HURD ;else if (strcasecmp (os,"freebsd" ) ==0 ) - sb->s_creator_os =EXT2_OS_FREEBSD ; + sb->s_creator_os =EXT2_OS_BSD ; +else if (strcasecmp (os,"netbsd" ) ==0 ) + sb->s_creator_os =EXT2_OS_BSD ; +else if (strcasecmp (os,"openbsd" ) ==0 ) + sb->s_creator_os =EXT2_OS_BSD ; +else if (strcasecmp (os,"dragonfly" ) ==0 ) + sb->s_creator_os =EXT2_OS_BSD ;else if (strcasecmp (os,"lites" ) ==0 ) sb->s_creator_os =EXT2_OS_LITES ;else
--
1.7.3.4
From 2c310b676a8fe9e1f2187aadcfc84cbeca07539d Mon Sep 17 00:00:00 2001
From: Antonio Huete Jimenez <[email protected]>
Date: Mon, 16 Jul 2012 01:25:55 +0200
Subject: [PATCH 2/2] Fix to support DragonFly BSD
- DragonFly uses DIOCGPART to return disk information.
--- lib/blkid/getsize.c | 15 ++++++++++++--- lib/ext2fs/getsize.c | 20 ++++++++++++++++---- lib/ext2fs/unix_io.c | 2 +- misc/util.c | 2 +- 4 files changed, 30 insertions(+), 9 deletions(-)
lib/blkid/getsize.c +12 -3
@@ -46,6 +46,9 @@#include <sys/stat.h> #endif +#ifdef __DragonFly__ +#include <sys/diskslice.h> +#endif #if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE )#define BLKGETSIZE _IO(0x12,96)/* return device size */
@@ -85,11 +88,10 @@ blkid_loff_t blkid_get_dev_size(int fd)#ifdef FDGETPRM struct floppy_struct this_floppy;#endif -#ifdef HAVE_SYS_DISKLABEL_H +#if defined(HAVE_SYS_DISKLABEL_H ) && !defined(__DragonFly__)int part =-1 ;struct disklabel lab;struct partition *pp; -char ch;struct stat st;#endif /* HAVE_SYS_DISKLABEL_H */
@@ -129,11 +131,18 @@ blkid_loff_t blkid_get_dev_size(int fd)return (off_t )size64;#endif /* DIOCGMEDIASIZE */ +/* tested on DragonFly 3.1-DEVELOPMENT i386/X86_64 */ +#ifdef DIOCGPART +struct partinfo dp; +if (ioctl (fd,DIOCGPART , &dp) >=0 ) +return (off_t )dp.media_size; +#endif /* DIOCGPART */ +#ifdef FDGETPRM if (ioctl (fd,FDGETPRM , &this_floppy) >=0 )return (blkid_loff_t )this_floppy.size <<9 ;#endif -#ifdef HAVE_SYS_DISKLABEL_H +#if defined(HAVE_SYS_DISKLABEL_H ) && !defined(__DragonFly__)/* * This code works for FreeBSD 4.11 i386, except for the full
device
* (such as /dev/ad0). It doesn't work properly for newer FreeBSD
lib/ext2fs/getsize.c +16 -4
@@ -46,6 +46,9 @@#include <sys/stat.h> #endif #include <ctype.h> +#ifdef __DragonFly__ +#include <sys/diskslice.h> +#endif #if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE )#define BLKGETSIZE _IO(0x12,96)/* return device size */
@@ -153,12 +156,12 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,#ifdef FDGETPRM struct floppy_struct this_floppy;#endif -#ifdef HAVE_SYS_DISKLABEL_H +#if defined(HAVE_SYS_DISKLABEL_H ) && !defined(__DragonFly__)int part;struct disklabel lab;struct partition *pp;char ch; -#endif /* HAVE_SYS_DISKLABEL_H */ +#endif /* HAVE_SYS_DISKLABEL_H && !defined(__DragonFly__) */ fd =ext2fs_open_file (file,O_RDONLY ,0 );if (fd <0 )
@@ -199,7 +202,7 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize, }#endif -#ifdef HAVE_SYS_DISKLABEL_H +#if defined(HAVE_SYS_DISKLABEL_H) #if defined(DIOCGMEDIASIZE) { off_t ms;
@@ -228,8 +231,17 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize, goto out; } } +#elif defined(DIOCGPART ) +/* DragonFly partition information */ +struct partinfo dp; +if (ioctl (fd,DIOCGPART , &dp) >=0 ) { + *retblocks = dp.media_size / blocksize; +printf ("success!\n" ); + goto out; + } +#endif /* defined(DIOCG*) */ -#endif /* HAVE_SYS_DISKLABEL_H */ +#endif /* HAVE_SYS_DISKLABEL_H && !defined(__DragonFly__) */ {ext2fs_struct_stat st;
lib/ext2fs/unix_io.c +1 -1
@@ -554,7 +554,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) io->flags |=CHANNEL_FLAGS_DISCARD_ZEROES ;#endif -#if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly)/* * Some operating systems require that the buffers be aligned, * regardless of O_DIRECT
misc/util.c +0 -0
@@ -93,7 +93,7 @@ void check_plausibility(const char *device) "did you specify it correctly?\n"),
stderr);
exit(1);
}
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
/* On FreeBSD, all disk devices are character specials */
if (!S_ISBLK(s.st_mode) && !S_ISCHR(s.st_mode)) #else
--
1.7.3.4
Quoted 3 lines · Antonio Huete Jiménez
I've pasted both new patches in this email with the intention of producing less traffic in the mailing list, but I'm unsure if this is the correct thing to do, opposed to sending one mail per patch.
It's better to send one mail per patch. The reason for that is we have automated tools that do the right thing with patches sent one per e-mail. This includes patchwork (which tracks patches sent to the mailing list; see
http://patchwork.ozlabs.org/project/linux-ext4/list/) and "git am".
Just use the git send-email tool; it will do the right thing.
There are places where you are using #if defined(__DragonFly__) and there are other places where you are using #ifdef DIOCGPART. Is there a reason for this?
In general, it's better to avoid using explicit feature tests rather things like defined(__Dragonfly__) or defined(__solaris__). What if an OS changes names or forks (i.e., like Open Solaris, Nextensa, Illumos, etc.).
And the combination of an #ifdef based on HAVE_SYS_DISKLABEL_H, DIOCGPART, and defined(__DragonFly__) raises red flags that the combinatorics may be very brittle in the long run.
Regards,
- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 Add support for DragonFly BSD operating system.
In reply to a message not in the archive2012/7/16 Theodore Ts'o <[email protected]>
Quoted 6 lines · Antonio Huete Jiménez
Quoted 3 lines
I've pasted both new patches in this email with the intention of producing less traffic in the mailing list, but I'm unsure if this is the correct thing to do, opposed to sending one mail per patch.
Quoted 7 lines
It's better to send one mail per patch. The reason for that is we have automated tools that do the right thing with patches sent one per e-mail. This includes patchwork (which tracks patches sent to the mailing list; see
http://patchwork.ozlabs.org/project/linux-ext4/list/) and "git am".Just use the git send-email tool; it will do the right thing.
I've used git send-email to send the patch that combines all BSDs into a single tag.
Quoted 5 lines
There are places where you are using #if
defined(__DragonFly__)and there are other places where you are using #ifdef DIOCGPART. Is there a reason for this?
I've used DIOCGPART because the rest of the code around uses DIOCGMEDIASIZE, DIOCGDINFO in a kind of sorted order, so I just copied the style.
Quoted 7 lines
In general, it's better to avoid using explicit feature tests rather things like
defined(__Dragonfly__)ordefined(__solaris__). What if an OS changes names or forks (i.e., like Open Solaris, Nextensa, Illumos, etc.).
Same could happen to the DIOCGDINFO #ifdefs, no?
Quoted 5 lines
And the combination of an #ifdef based on
HAVE_SYS_DISKLABEL_H, DIOCGPART, anddefined(__DragonFly__)raises red flags that the combinatorics may be very brittle in the long run.
Right but in some parts it is necessary to skip the code even if HAVE_SYS_DISKLABEL_H is defined. If you think there's a better way, just let me know and I'll change it righaway.
Quoted 4 lines
Regards,
- Ted
Cheers,
Antonio Huete
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html