mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
New API: rename: Rename file within the same filesystem (RHBZ#895910).
This commit is contained in:
@@ -158,6 +158,7 @@ guestfsd_SOURCES = \
|
||||
proto.c \
|
||||
readdir.c \
|
||||
realpath.c \
|
||||
rename.c \
|
||||
rsync.c \
|
||||
scrub.c \
|
||||
selinux.c \
|
||||
|
||||
41
daemon/rename.c
Normal file
41
daemon/rename.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/* libguestfs - the guestfsd daemon
|
||||
* Copyright (C) 2013 Red Hat Inc.
|
||||
*
|
||||
* 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 will 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 to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "daemon.h"
|
||||
#include "actions.h"
|
||||
|
||||
int
|
||||
do_rename (const char *oldpath, const char *newpath)
|
||||
{
|
||||
int r;
|
||||
|
||||
CHROOT_IN;
|
||||
r = rename (oldpath, newpath);
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("rename: %s: %s", oldpath, newpath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -4617,7 +4617,9 @@ recursively using the C<cp -a> command." };
|
||||
shortdesc = "move a file";
|
||||
longdesc = "\
|
||||
This moves a file from C<src> to C<dest> where C<dest> is
|
||||
either a destination filename or destination directory." };
|
||||
either a destination filename or destination directory.
|
||||
|
||||
See also: C<guestfs_rename>." };
|
||||
|
||||
{ defaults with
|
||||
name = "drop_caches";
|
||||
@@ -10679,6 +10681,23 @@ Return the type GUID of numbered GPT partition C<partnum>. For MBR partitions,
|
||||
return an appropriate GUID corresponding to the MBR type. Behaviour is undefined
|
||||
for other partition types." };
|
||||
|
||||
{ defaults with
|
||||
name = "rename";
|
||||
style = RErr, [Pathname "oldpath"; Pathname "newpath"], [];
|
||||
proc_nr = Some 394;
|
||||
tests = [
|
||||
InitScratchFS, Always, TestOutputFalse (
|
||||
[["mkdir"; "/rename"];
|
||||
["write"; "/rename/old"; "file content"];
|
||||
["rename"; "/rename/old"; "/rename/new"];
|
||||
["is_file"; "/rename/old"]])
|
||||
];
|
||||
shortdesc = "rename a file on the same filesystem";
|
||||
longdesc = "\
|
||||
Rename a file to a new place on the same filesystem. This is
|
||||
the same as the Linux L<rename(2)> system call. In most cases
|
||||
you are better to use C<guestfs_mv> instead." };
|
||||
|
||||
]
|
||||
|
||||
(* Non-API meta-commands available only in guestfish.
|
||||
|
||||
@@ -73,6 +73,7 @@ daemon/pingdaemon.c
|
||||
daemon/proto.c
|
||||
daemon/readdir.c
|
||||
daemon/realpath.c
|
||||
daemon/rename.c
|
||||
daemon/rsync.c
|
||||
daemon/scrub.c
|
||||
daemon/selinux.c
|
||||
|
||||
@@ -1 +1 @@
|
||||
393
|
||||
394
|
||||
|
||||
Reference in New Issue
Block a user