From: Karel Zak Date: Thu, 14 Dec 2023 09:06:06 +0000 (+0100) Subject: exch: cosmetic changes X-Git-Tag: v2.40-rc1~100 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8380ce7289f9d36e924ec544ec8c266da6dea837;p=thirdparty%2Futil-linux.git exch: cosmetic changes * use the same license header as in other utuls * make sure SYS_renamea2 defined * small change to usage() Signed-off-by: Karel Zak --- diff --git a/misc-utils/exch.1.adoc b/misc-utils/exch.1.adoc index fef78e8c08..b1c51d41ba 100644 --- a/misc-utils/exch.1.adoc +++ b/misc-utils/exch.1.adoc @@ -8,7 +8,7 @@ == NAME -exch - a command line interface for RENAME_EXCHANGE of renameat2(2) +exch - atomically exchanges paths between two files == SYNOPSIS diff --git a/misc-utils/exch.c b/misc-utils/exch.c index 0181bd9e6c..3a8e240eda 100644 --- a/misc-utils/exch.c +++ b/misc-utils/exch.c @@ -1,24 +1,16 @@ /* - * exch(1) - a command line interface for RENAME_EXCHANGE of renameat2(2). - * - * Copyright (C) 2023 Red Hat, Inc. All rights reserved. - * Written by Masatake YAMATO + * SPDX-License-Identifier: GPL-2.0-or-later * * 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; either version 2 of the License, or * (at your option) any later version. * - * 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. + * Copyright (C) 2023 Red Hat, Inc. All rights reserved. + * Written by Masatake YAMATO * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * exch(1) - a command line interface for RENAME_EXCHANGE of renameat2(2). */ - #include "c.h" #include "nls.h" @@ -26,20 +18,20 @@ #include #ifndef HAVE_RENAMEAT2 - -#include -#include +# include +# include +#endif #ifndef RENAME_EXCHANGE -#define RENAME_EXCHANGE (1 << 1) +# define RENAME_EXCHANGE (1 << 1) #endif +#if !defined(HAVE_RENAMEAT2) && defined(SYS_renamea2) static inline int renameat2(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags) { return syscall (SYS_renameat2, olddirfd, oldpath, newdirfd, newpath, flags); } - #endif static void __attribute__((__noreturn__)) usage(void) @@ -48,6 +40,8 @@ static void __attribute__((__noreturn__)) usage(void) fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] oldpath newpath\n"), program_invocation_short_name); + fputs(USAGE_SEPARATOR, out); + fputs(_("Atomically exchanges paths between two files.\n"), out); fputs(USAGE_OPTIONS, out); fprintf(out, USAGE_HELP_OPTIONS(30));