From 93660701e633547dedcd1099501f2ac6d7f44fee Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Tue, 4 Jan 2005 23:20:02 +0000 Subject: Multivolume: prevent file rename attempts across volumes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5535 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/fat.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'firmware/drivers') diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index b3f6891800..85bd525eff 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -1835,36 +1835,41 @@ int fat_rename(struct fat_file* file, struct fat_file newfile = *file; #ifdef HAVE_MULTIVOLUME struct bpb* fat_bpb = &fat_bpbs[file->volume]; + + if (file->volume != dir->file.volume) { + DEBUGF("No rename across volumes!\n"); + return -1; + } #endif if ( !file->dircluster ) { DEBUGF("File has no dir cluster!\n"); - return -1; + return -2; } /* create a temporary file handle */ rc = fat_opendir(IF_MV2(file->volume,) &olddir, file->dircluster, NULL); if (rc < 0) - return rc * 10 - 2; + return rc * 10 - 3; /* create new name */ rc = add_dir_entry(dir, &newfile, newname, false, false); if (rc < 0) - return rc * 10 - 3; + return rc * 10 - 4; /* write size and cluster link */ rc = update_short_entry(&newfile, size, attr); if (rc < 0) - return rc * 10 - 4; + return rc * 10 - 5; /* remove old name */ rc = free_direntries(file); if (rc < 0) - return rc * 10 - 5; + return rc * 10 - 6; rc = flush_fat(IF_MV(fat_bpb)); if (rc < 0) - return rc * 10 - 6; + return rc * 10 - 7; return 0; } -- cgit v1.2.3