From patchwork Wed Mar 21 03:19:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10298447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C32E4600F6 for ; Wed, 21 Mar 2018 03:19:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A69F52971D for ; Wed, 21 Mar 2018 03:19:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99A9E29727; Wed, 21 Mar 2018 03:19:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BE892971D for ; Wed, 21 Mar 2018 03:19:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751635AbeCUDTl (ORCPT ); Tue, 20 Mar 2018 23:19:41 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:51686 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751581AbeCUDTj (ORCPT ); Tue, 20 Mar 2018 23:19:39 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2L3BKD8024438; Wed, 21 Mar 2018 03:19:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=WaPMxT3SPFii20HNKFeF4sC/9SQ3Ne74Kj5taDTS9+E=; b=eE6WxlfRVPu5JqoXMfQmXR3bR+sAYCjQPyRC+JegprlafLmC0MWHTN+D5kR7RtTMvhu3 sHe7O2Xh/TKr8Gts0L1gZzerqzIhjhfpKtVBp9ly64cbeTamJjRwsGOqf5SDqP9AxY5/ zE/eexYe6xXVMfhN36fe3sHNW+ZqDmmb824ReHjeZsyrp4qIJ2oN2W/BZqb7xu2rdDGP K67QTTzYf+Wyr4nIy2DhcY6JCUDT41EGQdlwHVp6DwZgZFze4WTqzDeKVqkzjyej+Tdx DLLws65anacl2+5ZYM458jH2uxl+AEv4S7/aqfg4/Nt3PINIG0rByewTpZwWww+lc+zE Tg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2guf8v80h5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Mar 2018 03:19:36 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w2L3JZJY015476 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Mar 2018 03:19:35 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2L3JZmQ006796; Wed, 21 Mar 2018 03:19:35 GMT Received: from localhost (/10.159.242.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Mar 2018 20:19:34 -0700 Date: Tue, 20 Mar 2018 20:19:33 -0700 From: "Darrick J. Wong" To: sandeen@redhat.com Cc: linux-xfs@vger.kernel.org Subject: [PATCH 5/4] misc: remove darwin, irix, and freebsd support Message-ID: <20180321031933.GO1757@magnolia> References: <152151529988.18312.2660325658864402943.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <152151529988.18312.2660325658864402943.stgit@magnolia> User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8838 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803200127 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Remove these ports since they're not actively maintained: IRIX support was partially removed last year; the OS itself hasn't had a release since 2006. FreeBSD dropped XFS support in v9.3, which EOLd in January 2017. Darwin/OSX has never supported XFS. Signed-off-by: Darrick J. Wong --- include/darwin.h | 315 ----------------------------------------------------- include/freebsd.h | 210 ----------------------------------- libxfs/Makefile | 2 libxfs/darwin.c | 144 ------------------------ libxfs/freebsd.c | 201 ---------------------------------- libxfs/irix.c | 111 ------------------- 6 files changed, 1 insertion(+), 982 deletions(-) delete mode 100644 include/darwin.h delete mode 100644 include/freebsd.h delete mode 100644 libxfs/darwin.c delete mode 100644 libxfs/freebsd.c delete mode 100644 libxfs/irix.c -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/darwin.h b/include/darwin.h deleted file mode 100644 index 2632e1d..0000000 --- a/include/darwin.h +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Copyright (c) 2004-2006 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifndef __XFS_DARWIN_H__ -#define __XFS_DARWIN_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#define __BYTE_ORDER BYTE_ORDER -#define __BIG_ENDIAN BIG_ENDIAN -#define __LITTLE_ENDIAN LITTLE_ENDIAN - -#include -# ifndef SYS_fsctl -# define SYS_fsctl 242 -# endif - -#ifndef XATTR_LIST_MAX -#define XATTR_LIST_MAX 65536 -#endif - -static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p) -{ - return syscall(SYS_fsctl, path, cmd, p, 0); -} - -static __inline__ int platform_test_xfs_fd(int fd) -{ - struct statfs buf; - if (fstatfs(fd, &buf) < 0) - return 0; - return strncmp(buf.f_fstypename, "xfs", 4) == 0; -} - -static __inline__ int platform_test_xfs_path(const char *path) -{ - struct statfs buf; - if (statfs(path, &buf) < 0) - return 0; - return strncmp(buf.f_fstypename, "xfs", 4) == 0; -} - -static __inline__ int platform_fstatfs(int fd, struct statfs *buf) -{ - return fstatfs(fd, buf); -} - -static __inline__ void platform_getoptreset(void) -{ - extern int optreset; - optreset = 0; -} - -static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2) -{ - return uuid_compare(*uu1, *uu2); -} - -static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer) -{ - uuid_unparse(*uu, buffer); -} - -static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu) -{ - return uuid_parse(buffer, *uu); -} - -static __inline__ int platform_uuid_is_null(uuid_t *uu) -{ - return uuid_is_null(*uu); -} - -static __inline__ void platform_uuid_generate(uuid_t *uu) -{ - uuid_generate(*uu); -} - -static __inline__ void platform_uuid_clear(uuid_t *uu) -{ - uuid_clear(*uu); -} - -static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src) -{ - uuid_copy(*dst, *src); -} - -typedef unsigned char __u8; -typedef signed char __s8; -typedef unsigned short __u16; -typedef signed short __s16; -typedef unsigned int __u32; -typedef signed int __s32; -typedef unsigned long long int __u64; -typedef signed long long int __s64; - -#define int8_t int8_t -#define int16_t int16_t -#define int32_t int32_t -#define int32_t int32_t -#define int64_t int64_t - -typedef off_t xfs_off_t; -typedef uint64_t xfs_ino_t; -typedef uint32_t xfs_dev_t; -typedef int64_t xfs_daddr_t; -typedef __u32 xfs_nlink_t; - -#define fdatasync fsync -#define memalign(a,sz) valloc(sz) - -#define O_LARGEFILE 0 -#ifndef O_DIRECT -#define O_DIRECT 0 -#endif -#ifndef O_SYNC -#define O_SYNC 0 -#endif - -#define EFSCORRUPTED 990 /* Filesystem is corrupted */ -#define EFSBADCRC 991 /* Bad CRC detected */ - -#define HAVE_FID 1 - -static __inline__ int -platform_discard_blocks(int fd, uint64_t start, uint64_t len) -{ - return 0; -} - -/* - * POSIX timer replacement. - * It really just do the minimum we need for xfs_repair. - * Also, as setitimer can't create multiple timers, - * the timerid things are useless - we have only one ITIMER_REAL - * timer. - */ -#define CLOCK_REALTIME ITIMER_REAL -#define itimerspec itimerval -typedef uint64_t timer_t; -typedef double timer_c; -typedef clock_id_t clockid_t; - - -static inline int timer_create (clockid_t __clock_id, - struct sigevent *__restrict __evp, - timer_t *__restrict timer) -{ - // set something, to initialize the variable, just in case - *timer = 0; - return 0; -} - -static inline int timer_settime (timer_t timerid, int flags, - const struct itimerspec *__restrict timerspec, - struct itimerspec *__restrict ovalue) -{ - return setitimer(ITIMER_REAL, timerspec, ovalue); -} - -static inline int timer_delete (timer_t timerid) -{ - struct itimerspec timespec; - - timespec.it_interval.tv_sec=0; - timespec.it_interval.tv_usec=0; - timespec.it_value.tv_sec=0; - timespec.it_value.tv_usec=0; - - return setitimer(ITIMER_REAL, ×pec, NULL); -} - -static inline int timer_gettime (timer_t timerid, struct itimerspec *value) -{ - return getitimer(ITIMER_REAL, value); -} - -/* FSR */ - -# include -# include -#include -#include -#define _PATH_MOUNTED "/etc/mtab" - -struct mntent -{ - char *mnt_fsname; - char *mnt_dir; - char *mnt_type; - char *mnt_opts; - int mnt_freq; - int mnt_passno; -}; - -static inline void mntinfo2mntent (struct statfs * stats, struct mntent * mnt) { - mnt->mnt_fsname = stats->f_mntfromname; - mnt->mnt_dir = stats->f_mntonname; - mnt->mnt_type = stats->f_fstypename; -} - - - -/** - * Abstraction of mountpoints. - */ -struct mntent_cursor { - FILE *mtabp; - struct statfs *stats; - int count; - int i; -}; - -/** - * OS X uses getmntinfo, which doesn't use a mtab file. So we just ignore it. - */ -static inline int platform_mntent_open(struct mntent_cursor * cursor, char *mtab) -{ - if ((cursor->count = getmntinfo(&cursor->stats, 0)) < 0) { - fprintf(stderr, "Error: getmntinfo() failed: %s\n", strerror(errno)); - return 1; - } - cursor->i = 0; - return 0; -} - -static inline struct mntent * platform_mntent_next(struct mntent_cursor * cursor) -{ - struct mntent * t = NULL; - if (cursor->i >= cursor->count){ - return NULL; - } - mntinfo2mntent(&cursor->stats[cursor->i], t); - cursor->i++; - return t; -} - -static inline void platform_mntent_close(struct mntent_cursor * cursor) -{ - cursor->count = 0; - cursor->i = 0; -} - -/* check whether we have to define FS_IOC_FS[GS]ETXATTR ourselves */ -#ifndef HAVE_FSXATTR -struct fsxattr { - __u32 fsx_xflags; /* xflags field value (get/set) */ - __u32 fsx_extsize; /* extsize field value (get/set)*/ - __u32 fsx_nextents; /* nextents field value (get) */ - __u32 fsx_projid; /* project identifier (get/set) */ - __u32 fsx_cowextsize; /* cow extsize field value (get/set) */ - unsigned char fsx_pad[8]; -}; - -/* - * Flags for the fsx_xflags field - */ -#define FS_XFLAG_REALTIME 0x00000001 /* data in realtime volume */ -#define FS_XFLAG_PREALLOC 0x00000002 /* preallocated file extents */ -#define FS_XFLAG_IMMUTABLE 0x00000008 /* file cannot be modified */ -#define FS_XFLAG_APPEND 0x00000010 /* all writes append */ -#define FS_XFLAG_SYNC 0x00000020 /* all writes synchronous */ -#define FS_XFLAG_NOATIME 0x00000040 /* do not update access time */ -#define FS_XFLAG_NODUMP 0x00000080 /* do not include in backups */ -#define FS_XFLAG_RTINHERIT 0x00000100 /* create with rt bit set */ -#define FS_XFLAG_PROJINHERIT 0x00000200 /* create with parents projid */ -#define FS_XFLAG_NOSYMLINKS 0x00000400 /* disallow symlink creation */ -#define FS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */ -#define FS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */ -#define FS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */ -#define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */ -#define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */ -#define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ - -#define FS_IOC_FSGETXATTR _IOR ('X', 31, struct fsxattr) -#define FS_IOC_FSSETXATTR _IOW ('X', 32, struct fsxattr) - -#endif - -#ifndef FS_XFLAG_COWEXTSIZE -#define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */ -#endif - -#endif /* __XFS_DARWIN_H__ */ diff --git a/include/freebsd.h b/include/freebsd.h deleted file mode 100644 index f52ed0a..0000000 --- a/include/freebsd.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2004-2006 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifndef __XFS_FREEBSD_H__ -#define __XFS_FREEBSD_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#define __BYTE_ORDER BYTE_ORDER -#define __BIG_ENDIAN BIG_ENDIAN -#define __LITTLE_ENDIAN LITTLE_ENDIAN - -/* FreeBSD file API is 64-bit aware */ -#define fdatasync fsync -#define memalign(a,sz) valloc(sz) - -#define EFSCORRUPTED 990 /* Filesystem is corrupted */ -#define EFSBADCRC 991 /* Bad CRC detected */ - -typedef unsigned char __u8; -typedef signed char __s8; -typedef unsigned short __u16; -typedef signed short __s16; -typedef unsigned int __u32; -typedef signed int __s32; -typedef unsigned long long int __u64; -typedef signed long long int __s64; - -typedef off_t xfs_off_t; -typedef uint64_t xfs_ino_t; -typedef uint32_t xfs_dev_t; -typedef int64_t xfs_daddr_t; -typedef __u32 xfs_nlink_t; - -#define O_LARGEFILE 0 - -#define HAVE_FID 1 - -static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p) -{ - return ioctl(fd, cmd, p); -} - -static __inline__ int platform_test_xfs_fd(int fd) -{ - struct statfs buf; - if (fstatfs(fd, &buf) < 0) - return 0; - return strncmp(buf.f_fstypename, "xfs", 4) == 0; -} - -static __inline__ int platform_test_xfs_path(const char *path) -{ - struct statfs buf; - if (statfs(path, &buf) < 0) - return 0; - return strncmp(buf.f_fstypename, "xfs", 4) == 0; -} - -static __inline__ int platform_fstatfs(int fd, struct statfs *buf) -{ - return fstatfs(fd, buf); -} - -static __inline__ void platform_getoptreset(void) -{ - extern int optind; - optind = 0; -} - -static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2) -{ - return uuid_compare(uu1, uu2, NULL); -} - -static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer) -{ - uint32_t status; - char *s; - uuid_to_string(uu, &s, &status); - if (status == uuid_s_ok) - strcpy(buffer, s); - else buffer[0] = '\0'; - free(s); -} - -static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu) -{ - uint32_t status; - uuid_from_string(buffer, uu, &status); - return (status == uuid_s_ok); -} - -static __inline__ int platform_uuid_is_null(uuid_t *uu) -{ - return uuid_is_nil(uu, NULL); -} - -static __inline__ void platform_uuid_generate(uuid_t *uu) -{ - uuid_create(uu, NULL); -} - -static __inline__ void platform_uuid_clear(uuid_t *uu) -{ - uuid_create_nil(uu, NULL); -} - -static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src) -{ - memcpy(dst, src, sizeof(uuid_t)); -} - -static __inline__ int -platform_discard_blocks(int fd, uint64_t start, uint64_t len) -{ - return 0; -} - -/** - * Abstraction of mountpoints. - */ -struct mntent_cursor { - FILE *mtabp; -}; - -static inline int platform_mntent_open(struct mntent_cursor * cursor, char *mtab) -{ - cursor->mtabp = setmntent(mtab, "r"); - if (!cursor->mtabp) { - fprintf(stderr, "Error: cannot read %s\n", mtab); - return 1; - } - return 0; -} - -static inline struct mntent * platform_mntent_next(struct mntent_cursor * cursor) -{ - return getmntent(cursor->mtabp); -} - -static inline void platform_mntent_close(struct mntent_cursor * cursor) -{ - endmntent(cursor->mtabp); -} - -/* check whether we have to define FS_IOC_FS[GS]ETXATTR ourselves */ -#ifndef HAVE_FSXATTR -struct fsxattr { - __u32 fsx_xflags; /* xflags field value (get/set) */ - __u32 fsx_extsize; /* extsize field value (get/set)*/ - __u32 fsx_nextents; /* nextents field value (get) */ - __u32 fsx_projid; /* project identifier (get/set) */ - __u32 fsx_cowextsize; /* cow extsize field value (get/set) */ - unsigned char fsx_pad[8]; -}; - -/* - * Flags for the fsx_xflags field - */ -#define FS_XFLAG_REALTIME 0x00000001 /* data in realtime volume */ -#define FS_XFLAG_PREALLOC 0x00000002 /* preallocated file extents */ -#define FS_XFLAG_IMMUTABLE 0x00000008 /* file cannot be modified */ -#define FS_XFLAG_APPEND 0x00000010 /* all writes append */ -#define FS_XFLAG_SYNC 0x00000020 /* all writes synchronous */ -#define FS_XFLAG_NOATIME 0x00000040 /* do not update access time */ -#define FS_XFLAG_NODUMP 0x00000080 /* do not include in backups */ -#define FS_XFLAG_RTINHERIT 0x00000100 /* create with rt bit set */ -#define FS_XFLAG_PROJINHERIT 0x00000200 /* create with parents projid */ -#define FS_XFLAG_NOSYMLINKS 0x00000400 /* disallow symlink creation */ -#define FS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */ -#define FS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */ -#define FS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */ -#define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */ -#define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */ -#define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ - -#define FS_IOC_FSGETXATTR _IOR ('X', 31, struct fsxattr) -#define FS_IOC_FSSETXATTR _IOW ('X', 32, struct fsxattr) - -#endif - -#ifndef FS_XFLAG_COWEXTSIZE -#define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */ -#endif - -#endif /* __XFS_FREEBSD_H__ */ diff --git a/libxfs/Makefile b/libxfs/Makefile index 0470f5f..00df418 100644 --- a/libxfs/Makefile +++ b/libxfs/Makefile @@ -98,7 +98,7 @@ CFILES = cache.c \ xfs_trans_resv.c CFILES += $(PKG_PLATFORM).c -PCFILES = darwin.c freebsd.c irix.c linux.c +PCFILES = linux.c LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g") LSRCFILES += gen_crc32table.c diff --git a/libxfs/darwin.c b/libxfs/darwin.c deleted file mode 100644 index 16d2c35..0000000 --- a/libxfs/darwin.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2003,2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include "libxfs.h" - -int platform_has_uuid = 1; -extern char *progname; - -int -platform_check_ismounted(char *name, char *block, struct stat *s, int verbose) -{ - return 0; -} - -int -platform_check_iswritable(char *name, char *block, struct stat *s) -{ - int fd, writable; - - if ((fd = open(block, O_RDONLY, 0)) < 0) { - fprintf(stderr, _("%s: " - "error opening the device special file \"%s\": %s\n"), - progname, block, strerror(errno)); - exit(1); - } - - if (ioctl(fd, DKIOCISWRITABLE, &writable) < 0) { - fprintf(stderr, _("%s: can't tell if \"%s\" is writable: %s\n"), - progname, block, strerror(errno)); - exit(1); - } - close(fd); - return writable == 0; -} - -int -platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal) -{ - return fatal; -} - -void -platform_flush_device(int fd, dev_t device) -{ - ioctl(fd, DKIOCSYNCHRONIZECACHE, NULL); -} - -void -platform_findsizes(char *path, int fd, long long *sz, int *bsz) -{ - uint64_t size; - struct stat st; - - if (fstat(fd, &st) < 0) { - fprintf(stderr, - _("%s: cannot stat the device file \"%s\": %s\n"), - progname, path, strerror(errno)); - exit(1); - } - if ((st.st_mode & S_IFMT) == S_IFREG) { - *sz = (long long)(st.st_size >> 9); - *bsz = BBSIZE; - return; - } - if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size) < 0) { - fprintf(stderr, _("%s: can't determine device size: %s\n"), - progname, strerror(errno)); - exit(1); - } - *sz = (long long)size; - *bsz = BBSIZE; -} - -char * -platform_findrawpath(char *path) -{ - return path; -} - -char * -platform_findblockpath(char *path) -{ - return path; -} - -int -platform_direct_blockdev(void) -{ - return 0; -} - -int -platform_align_blockdev(void) -{ - return sizeof(void *); -} - -int -platform_nproc(void) -{ - int ncpu; - size_t len = sizeof(ncpu); - static int mib[2] = {CTL_HW, HW_NCPU}; - - if (sysctl(mib, 2, &ncpu, &len, NULL, 0) < 0) - ncpu = 1; - - return ncpu; -} - -unsigned long -platform_physmem(void) -{ - unsigned long physmem; - size_t len = sizeof(physmem); - static int mib[2] = {CTL_HW, HW_PHYSMEM}; - - if (sysctl(mib, 2, &physmem, &len, NULL, 0) < 0) { - fprintf(stderr, _("%s: can't determine memory size\n"), - progname); - exit(1); - } - return physmem >> 10; -} diff --git a/libxfs/freebsd.c b/libxfs/freebsd.c deleted file mode 100644 index 5b9ef29..0000000 --- a/libxfs/freebsd.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2003,2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libxfs.h" -#include -#include -#include -#include -#include - -int platform_has_uuid = 1; -extern char *progname; - -int -platform_check_ismounted(char *name, char *block, struct stat *s, int verbose) -{ - struct stat st; - int cnt, i; - struct statfs *fsinfo; - - if (!s) { - if (stat(block, &st) < 0) - return 0; - s = &st; - } - - /* Remember, FreeBSD can now mount char devices! -- adrian */ - if (((st.st_mode & S_IFMT) != S_IFBLK) && - ((st.st_mode & S_IFMT) != S_IFCHR)) - return 0; - - if ((cnt = getmntinfo(&fsinfo, MNT_NOWAIT)) == 0) { - fprintf(stderr, - _("%s: %s possibly contains a mounted filesystem\n"), - progname, name); - return 1; - } - - for (i = 0; i < cnt; i++) { - if (strcmp (name, fsinfo[i].f_mntfromname) != 0) - continue; - - if (verbose) - fprintf(stderr, - _("%s: %s contains a mounted filesystem\n"), - progname, name); - break; - } - - return i < cnt; -} - -int -platform_check_iswritable(char *name, char *block, struct stat *s) -{ - int cnt, i; - struct statfs *fsinfo; - - if ((cnt = getmntinfo(&fsinfo, MNT_NOWAIT)) == 0) { - fprintf(stderr, _("%s: %s contains a possibly writable, " - "mounted filesystem\n"), progname, name); - return 1; - } - - for (i = 0; i < cnt; i++) { - if (strcmp (name, fsinfo[i].f_mntfromname) != 0) - continue; - - if (fsinfo[i].f_flags &= MNT_RDONLY) - break; - } - - if (i == cnt) { - fprintf(stderr, _("%s: %s contains a mounted and writable " - "filesystem\n"), progname, name); - return 1; - } - return 0; -} - -int -platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal) -{ - return fatal; -} - -void -platform_flush_device(int fd, dev_t device) -{ - return; -} - -void -platform_findsizes(char *path, int fd, long long *sz, int *bsz) -{ - struct stat st; - int64_t size; - uint ssize; - - if (fstat(fd, &st) < 0) { - fprintf(stderr, _("%s: " - "cannot stat the device file \"%s\": %s\n"), - progname, path, strerror(errno)); - exit(1); - } - - if ((st.st_mode & S_IFMT) == S_IFREG) { - *sz = (long long)(st.st_size >> 9); - *bsz = 512; - return; - } - - if ((st.st_mode & S_IFMT) != S_IFCHR) { - fprintf(stderr, _("%s: Not a device or file: \"%s\"\n"), - progname, path); - exit(1); - } - - if (ioctl(fd, DIOCGMEDIASIZE, &size) != 0) { - fprintf(stderr, _("%s: DIOCGMEDIASIZE failed on \"%s\": %s\n"), - progname, path, strerror(errno)); - exit(1); - } - - if (ioctl(fd, DIOCGSECTORSIZE, &ssize) != 0) { - fprintf(stderr, _("%s: " - "DIOCGSECTORSIZE failed on \"%s\": %s\n"), - progname, path, strerror(errno)); - exit(1); - } - - *sz = (long long) (size / ssize); - *bsz = (int)ssize; -} - -char * -platform_findrawpath(char *path) -{ - return path; -} - -char * -platform_findblockpath(char *path) -{ - return path; -} - -int -platform_direct_blockdev(void) -{ - return 0; -} - -int -platform_align_blockdev(void) -{ - return sizeof(void *); -} - -int -platform_nproc(void) -{ - int ncpu; - size_t len = sizeof(ncpu); - static int mib[2] = {CTL_HW, HW_NCPU}; - - if (sysctl(mib, 2, &ncpu, &len, NULL, 0) < 0) - ncpu = 1; - - return ncpu; -} - -unsigned long -platform_physmem(void) -{ - unsigned long physmem; - size_t len = sizeof(physmem); - static int mib[2] = {CTL_HW, HW_PHYSMEM}; - - if (sysctl(mib, 2, &physmem, &len, NULL, 0) < 0) { - fprintf(stderr, _("%s: can't determine memory size\n"), - progname); - exit(1); - } - return physmem >> 10; -} diff --git a/libxfs/irix.c b/libxfs/irix.c deleted file mode 100644 index 0f14aec..0000000 --- a/libxfs/irix.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libxfs.h" -#include -#include - -int platform_has_uuid = 0; -extern char *progname; -extern int64_t findsize(char *); - -int -platform_check_ismounted(char *name, char *block, struct stat *s, int verbose) -{ - return 0; -} - -int -platform_check_iswritable(char *name, char *block, struct stat *s) -{ - return 1; -} - -int -platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal) -{ - return fatal; -} - -void -platform_flush_device(int fd, dev_t device) -{ - return; -} - -void -platform_findsizes(char *path, int fd, long long *sz, int *bsz) -{ - struct stat st; - - if (fstat(fd, &st) < 0) { - fprintf(stderr, - _("%s: cannot stat the device file \"%s\": %s\n"), - progname, path, strerror(errno)); - exit(1); - } - if ((st.st_mode & S_IFMT) == S_IFREG) { - *sz = (long long)(st.st_size >> 9); - } else { - *sz = findsize(path); - } - *bsz = BBSIZE; -} - -char * -platform_findrawpath(char *path) -{ - return findrawpath(path); -} - -char * -platform_findblockpath(char *path) -{ - return findblockpath(path); -} - -int -platform_direct_blockdev(void) -{ - return 0; -} - -int -platform_align_blockdev(void) -{ - return sizeof(void *); -} - -int -platform_nproc(void) -{ - return sysmp(MP_NPROCS); -} - -unsigned long -platform_physmem(void) -{ - struct rminfo ri; - - if (sysmp(MP_SAGET, MPSA_RMINFO, &ri, sizeof(ri)) < 0) - fprintf(stderr, _("%s: can't determine memory size\n"), - progname); - exit(1); - } - return (ri.physmem >> 10) * getpagesize(); /* kilobytes */ -}