+// 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] source target\n"), progname);
+ fprintf(stderr, _("%s [-e extsize] [-p] [-V] source target\n"), progname);
exit(2);
}
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]);
* 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);
}
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;
*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);
}
* 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)
* 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
*/
/*
* 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));
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));
/*
* 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 );
return( -1 );
}
fprintf(stderr, _("%s: %s file extent size is %d, "
"instead of %d.\n"),
progname, tbuf, fsxattr.fsx_extsize, fextsize);
+ close( tofd );
return( -1 );
}
}
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;
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 ) {
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;