Subversion Repositories Spectranet

Compare Revisions

Rev 265 → Rev 288

/tnfs-protocol.txt
529,6 → 529,17
 
The reply is the standard header plus the return code of the chmod operation.
 
RENAME - Moves a file within a filesystem - Command 0x28
--------------------------------------------------------
Renames a file (or moves a file within a filesystem - it must be possible
to move a file to a different directory within the same FS on the
server using this command).
The request consists of the header, followed by the null terminated
source path, and the null terminated destination path.
 
Example: Move file "foo.txt" to "bar.txt"
0xBEEF 0x00 0x28 foo.txt 0x00 bar.txt 0x00
 
DEVICE OPERATIONS
=================
These operations get information about the device that is mounted.
/tnfs-perl/tnfsd.pl
41,7 → 41,8
0x24 => \&statFile,
0x25 => \&seekFile,
0x26 => \&unlinkFile,
0x27 => \&chmodFile );
0x27 => \&chmodFile,
0x28 => \&renameFile );
 
# File modes
my %MODE=( 0x01 => O_RDONLY,
423,7 → 424,11
{
my ($session, $cmd, $status, $msg)=@_;
my ($clientHandle, $seektype, $seekloc)=unpack("CCl", $msg);
my ($clientHandle, $seektype, $seekloc)=unpack("CCV", $msg);
if($seekloc & 8000000)
{
$seekloc = -$seekloc;
}
#print("seekFile: handle=$clientHandle type=$seektype loc=$seekloc\n");
my $fhnd=$FILEHANDLE{$session}->[$clientHandle];
if(defined $fhnd)
512,6 → 517,26
}
}
 
# renameFile - moves a file within the filesystem (0x28)
sub renameFile
{
my ($session, $cmd, $status, $msg)=@_;
 
# separate out "from" and "to" paths.
my ($from, $to)=split(/\x00/, $msg);
$from = $MOUNTPOINT{$session} . $from;
$to = $MOUNTPOINT{$session} . $to;
print("rename: $from => $to\n");
if(rename($from, $to))
{
sendMsg($session, 0x28, 0x00);
}
else
{
sendMsg($session, 0x28, int($!));
}
}
 
sub sendMsg
{
my ($session, $cmd, $status, $msg)=@_;