]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - rtcp/xfs_rtcp.c
xfsprogs: Release v6.8.0
[thirdparty/xfsprogs-dev.git] / rtcp / xfs_rtcp.c
index b81b1e1b42654afb0641391b75fc7a3e9538ac6b..7c4197b1314ceb1a6e6d8075ab6d0582da2eb459 100644 (file)
@@ -1,31 +1,20 @@
+// SPDX-License-Identifier: GPL-2.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 "libxfs.h"
+#include "libfrog/fsgeom.h"
 
 int rtcp(char *, char *, int);
 int xfsrtextsize(char *path);
 
-int pflag;
+static int pflag;
 char *progname;
 
-void
-usage()
+static void
+usage(void)
 {
        fprintf(stderr, _("%s [-e extsize] [-p] [-V] source target\n"), progname);
        exit(2);
@@ -34,8 +23,8 @@ usage()
 int
 main(int argc, char **argv)
 {
-       register int    c, i, r, errflg = 0;
-       struct stat64   s2;
+       int     c, i, r, errflg = 0;
+       struct stat     s2;
        int             extsize = - 1;
 
        progname = basename(argv[0]);
@@ -80,8 +69,8 @@ main(int argc, char **argv)
         * which really exists.
         */
        if (argc > 2) {
-               if (stat64(argv[argc-1], &s2) < 0) {
-                       fprintf(stderr, _("%s: stat64 of %s failed\n"),
+               if (stat(argv[argc-1], &s2) < 0) {
+                       fprintf(stderr, _("%s: stat of %s failed\n"),
                                progname, argv[argc-1]);
                        exit(2);
                }
@@ -115,7 +104,7 @@ rtcp( char *source, char *target, int fextsize)
        int             remove = 0, rtextsize;
        char            *sp, *fbuf, *ptr;
        char            tbuf[ PATH_MAX ];
-       struct stat64   s1, s2;
+       struct stat     s1, s2;
        struct fsxattr  fsxattr;
        struct dioattr  dioattr;
 
@@ -134,8 +123,8 @@ rtcp( char *source, char *target, int fextsize)
                        *sp = '\0';
        }
 
-       if ( stat64(source, &s1) ) {
-               fprintf(stderr, _("%s: failed stat64 on %s: %s\n"),
+       if ( stat(source, &s1) ) {
+               fprintf(stderr, _("%s: failed stat on %s: %s\n"),
                        progname, source, strerror(errno));
                return( -1);
        }
@@ -144,7 +133,7 @@ rtcp( char *source, char *target, int fextsize)
         * check for a realtime partition
         */
        snprintf(tbuf, sizeof(tbuf), "%s", target);
-       if ( stat64(target, &s2) ) {
+       if ( stat(target, &s2) ) {
                if (!S_ISDIR(s2.st_mode)) {
                        /* take out target file name */
                        if ((ptr = strrchr(tbuf, '/')) != NULL)
@@ -165,14 +154,14 @@ rtcp( char *source, char *target, int fextsize)
         * check if target is a directory
         */
        snprintf(tbuf, sizeof(tbuf), "%s", target);
-       if ( !stat64(target, &s2) ) {
+       if ( !stat(target, &s2) ) {
                if (S_ISDIR(s2.st_mode)) {
                        snprintf(tbuf, sizeof(tbuf), "%s/%s", target,
                                basename(source));
                }
        }
 
-       if ( stat64(tbuf, &s2) ) {
+       if ( stat(tbuf, &s2) ) {
                /*
                 * create the file if it does not exist
                 */
@@ -186,13 +175,13 @@ rtcp( char *source, char *target, int fextsize)
                /*
                 * mark the file as a realtime file
                 */
-               fsxattr.fsx_xflags = XFS_XFLAG_REALTIME;
+               fsxattr.fsx_xflags = FS_XFLAG_REALTIME;
                if (fextsize != -1 )
                        fsxattr.fsx_extsize = fextsize;
                else
                        fsxattr.fsx_extsize = 0;
 
-               if ( xfsctl(tbuf, tofd, XFS_IOC_FSSETXATTR, &fsxattr) ) {
+               if ( xfsctl(tbuf, tofd, FS_IOC_FSSETXATTR, &fsxattr) ) {
                        fprintf(stderr,
                                _("%s: set attributes on %s failed: %s\n"),
                                progname, tbuf, strerror(errno));
@@ -210,7 +199,7 @@ rtcp( char *source, char *target, int fextsize)
                        return( -1 );
                }
 
-               if ( xfsctl(tbuf, tofd, XFS_IOC_FSGETXATTR, &fsxattr) ) {
+               if ( xfsctl(tbuf, tofd, FS_IOC_FSGETXATTR, &fsxattr) ) {
                        fprintf(stderr,
                                _("%s: get attributes of %s failed: %s\n"),
                                progname, tbuf, strerror(errno));
@@ -221,7 +210,7 @@ rtcp( char *source, char *target, int fextsize)
                /*
                 * check if the existing file is already a realtime file
                 */
-               if ( !(fsxattr.fsx_xflags & XFS_XFLAG_REALTIME) ) {
+               if ( !(fsxattr.fsx_xflags & FS_XFLAG_REALTIME) ) {
                        fprintf(stderr, _("%s: %s is not a realtime file.\n"),
                                progname, tbuf);
                        close( tofd );
@@ -255,10 +244,10 @@ rtcp( char *source, char *target, int fextsize)
 
        fsxattr.fsx_xflags = 0;
        fsxattr.fsx_extsize = 0;
-       if ( xfsctl(source, fromfd, XFS_IOC_FSGETXATTR, &fsxattr) ) {
+       if ( xfsctl(source, fromfd, FS_IOC_FSGETXATTR, &fsxattr) ) {
                reopen = 1;
        } else {
-               if (! (fsxattr.fsx_xflags & XFS_XFLAG_REALTIME) ){
+               if (! (fsxattr.fsx_xflags & FS_XFLAG_REALTIME) ){
                        fprintf(stderr, _("%s: %s is not a realtime file.\n"),
                                progname, source);
                        reopen = 1;
@@ -380,8 +369,8 @@ rtcp( char *source, char *target, int fextsize)
 int
 xfsrtextsize( char *path)
 {
-       int fd, rval, rtextsize;
-       xfs_fsop_geom_v1_t geo;
+       struct xfs_fsop_geom    geo;
+       int                     fd, rval, rtextsize;
 
        fd = open( path, O_RDONLY );
        if ( fd < 0 ) {
@@ -389,9 +378,9 @@ xfsrtextsize( char *path)
                        progname, path, strerror(errno));
                return -1;
        }
-       rval = xfsctl( path, fd, XFS_IOC_FSGEOMETRY_V1, &geo );
+       rval = -xfrog_geometry(fd, &geo);
        close(fd);
-       if ( rval < 0 )
+       if (rval)
                return -1;
 
        rtextsize = geo.rtextsize * geo.blocksize;