#include <sys/types.h>
#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
#include <blkid/blkid.h>
extern void blkid_debug_dump_tag(blkid_tag tag);
#endif
+static inline int blkidP_is_disk_device(mode_t mode)
+{
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ return S_ISBLK(mode) || S_ISCHR(mode);
+#else
+ return S_ISBLK(mode);
+#endif
+}
+
/* devno.c */
struct dir_list {
char *name;
dev->bid_devno == devno)
goto set_pri;
- if (stat(device, &st) == 0 && S_ISBLK(st.st_mode) &&
+ if (stat(device, &st) == 0 &&
+ blkidP_is_disk_device(st.st_mode) &&
st.st_rdev == devno) {
devname = blkid_strdup(device);
goto get_dev;
if (stat(path, &st) < 0)
continue;
- if (S_ISBLK(st.st_mode) && st.st_rdev == devno) {
+ if (blkidP_is_disk_device(st.st_mode) && st.st_rdev == devno) {
*devname = blkid_strdup(path);
DBG(DEBUG_DEVNO,
printf("found 0x%llx at %s (%p)\n", (long long)devno,
* character) devices, so we need to check for S_ISCHR, too.
*/
if (fstat(fd, &st) >= 0 &&
- (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)))
+ blkidP_is_disk_device(st.st_mode))
part = st.st_rdev & 7;
if (part >= 0 && (ioctl(fd, DIOCGDINFO, (char *)&lab) >= 0)) {
* %End-Header%
*/
+#include "config.h"
#include <stdio.h>
#include <string.h>
#if HAVE_UNISTD_H
* %End-Header%
*/
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
#include "ext2fs.h"
#define EXT2FS_MAX_NESTED_LINKS 8
+static inline int ext2fsP_is_disk_device(mode_t mode)
+{
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ return S_ISBLK(mode) || S_ISCHR(mode);
+#else
+ return S_ISBLK(mode);
+#endif
+}
+
/*
* Badblocks list
*/
goto skip_to_next;
if (S_ISDIR(st.st_mode))
add_to_dirlist(path, list);
- if (S_ISBLK(st.st_mode) && st.st_rdev == device) {
+ if (ext2fsP_is_disk_device(st.st_mode) &&
+ st.st_rdev == device) {
cp = malloc(strlen(path)+1);
if (!cp) {
closedir(dir);
#include "ext2_fs.h"
#include "ext2fs.h"
+#include "ext2fsP.h"
#ifdef HAVE_SETMNTENT
/*
return errno;
}
if (stat(file, &st_buf) == 0) {
- if (S_ISBLK(st_buf.st_mode)) {
+ if (ext2fsP_is_disk_device(st_buf.st_mode)) {
#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
file_rdev = st_buf.st_rdev;
#endif /* __GNU__ */
if (strcmp(file, mnt->mnt_fsname) == 0)
break;
if (stat(mnt->mnt_fsname, &st_buf) == 0) {
- if (S_ISBLK(st_buf.st_mode)) {
+ if (ext2fsP_is_disk_device(st_buf.st_mode)) {
#ifndef __GNU__
if (file_rdev && (file_rdev == st_buf.st_rdev))
break;
file_dev = 0;
#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
if ((stat(file, &st_buf) == 0) &&
- S_ISBLK(st_buf.st_mode))
+ ext2fsP_is_disk_device(st_buf.st_mode))
file_dev = st_buf.st_rdev;
#endif /* __GNU__ */
}
#ifndef __GNU__
if (file_dev && (stat(buf, &st_buf) == 0) &&
- S_ISBLK(st_buf.st_mode) &&
+ ext2fsP_is_disk_device(st_buf.st_mode) &&
file_dev == st_buf.st_rdev) {
ret++;
break;
{
struct stat st_buf;
- if (stat(device, &st_buf) == 0 && S_ISBLK(st_buf.st_mode)) {
+ if (stat(device, &st_buf) == 0 &&
+ ext2fsP_is_disk_device(st_buf.st_mode)) {
int fd = open(device, O_RDONLY | O_EXCL);
if (fd >= 0)
#include "ext2_fs.h"
#include "ext2fs.h"
+#include "ext2fsP.h"
/*
* For checking structure magic numbers...
* zero.
*/
if (ext2fs_fstat(data->dev, &st) == 0) {
- if (S_ISBLK(st.st_mode))
+ if (ext2fsP_is_disk_device(st.st_mode))
io->flags |= CHANNEL_FLAGS_BLOCK_DEVICE;
else
io->flags |= CHANNEL_FLAGS_DISCARD_ZEROES;
(ut.release[4] == '1') && (ut.release[5] >= '0') &&
(ut.release[5] < '8')) &&
(ext2fs_fstat(data->dev, &st) == 0) &&
- (S_ISBLK(st.st_mode))) {
+ (ext2fsP_is_disk_device(st.st_mode))) {
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = (unsigned long) RLIM_INFINITY;
#include "ext2fs/ext2_fs.h"
#include "ext2fs/ext2fs.h"
+#include "ext2fs/ext2fsP.h"
#include "et/com_err.h"
#include "uuid/uuid.h"
#include "e2p/e2p.h"
_("Can not stat output\n"));
exit(1);
}
- if (S_ISBLK(st.st_mode))
+ if (ext2fsP_is_disk_device(st.st_mode))
output_is_blk = 1;
}
if (flags & E2IMAGE_IS_QCOW2_FLAG) {