summaryrefslogtreecommitdiff
path: root/firmware/drivers/fat.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/fat.c')
-rw-r--r--firmware/drivers/fat.c17
1 files changed, 11 insertions, 6 deletions
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,
1835 struct fat_file newfile = *file; 1835 struct fat_file newfile = *file;
1836#ifdef HAVE_MULTIVOLUME 1836#ifdef HAVE_MULTIVOLUME
1837 struct bpb* fat_bpb = &fat_bpbs[file->volume]; 1837 struct bpb* fat_bpb = &fat_bpbs[file->volume];
1838
1839 if (file->volume != dir->file.volume) {
1840 DEBUGF("No rename across volumes!\n");
1841 return -1;
1842 }
1838#endif 1843#endif
1839 1844
1840 if ( !file->dircluster ) { 1845 if ( !file->dircluster ) {
1841 DEBUGF("File has no dir cluster!\n"); 1846 DEBUGF("File has no dir cluster!\n");
1842 return -1; 1847 return -2;
1843 } 1848 }
1844 1849
1845 /* create a temporary file handle */ 1850 /* create a temporary file handle */
1846 rc = fat_opendir(IF_MV2(file->volume,) &olddir, file->dircluster, NULL); 1851 rc = fat_opendir(IF_MV2(file->volume,) &olddir, file->dircluster, NULL);
1847 if (rc < 0) 1852 if (rc < 0)
1848 return rc * 10 - 2; 1853 return rc * 10 - 3;
1849 1854
1850 /* create new name */ 1855 /* create new name */
1851 rc = add_dir_entry(dir, &newfile, newname, false, false); 1856 rc = add_dir_entry(dir, &newfile, newname, false, false);
1852 if (rc < 0) 1857 if (rc < 0)
1853 return rc * 10 - 3; 1858 return rc * 10 - 4;
1854 1859
1855 /* write size and cluster link */ 1860 /* write size and cluster link */
1856 rc = update_short_entry(&newfile, size, attr); 1861 rc = update_short_entry(&newfile, size, attr);
1857 if (rc < 0) 1862 if (rc < 0)
1858 return rc * 10 - 4; 1863 return rc * 10 - 5;
1859 1864
1860 /* remove old name */ 1865 /* remove old name */
1861 rc = free_direntries(file); 1866 rc = free_direntries(file);
1862 if (rc < 0) 1867 if (rc < 0)
1863 return rc * 10 - 5; 1868 return rc * 10 - 6;
1864 1869
1865 rc = flush_fat(IF_MV(fat_bpb)); 1870 rc = flush_fat(IF_MV(fat_bpb));
1866 if (rc < 0) 1871 if (rc < 0)
1867 return rc * 10 - 6; 1872 return rc * 10 - 7;
1868 1873
1869 return 0; 1874 return 0;
1870} 1875}