summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/fat.c13
-rw-r--r--firmware/drivers/fat.h4
2 files changed, 10 insertions, 7 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 020a48bdef..9274a9c339 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -1122,7 +1122,7 @@ static int create_dos_name(unsigned char *name, unsigned char *newname)
1122 return 0; 1122 return 0;
1123} 1123}
1124 1124
1125static int update_file_size( struct fat_file* file, int size ) 1125static int update_short_entry( struct fat_file* file, int size, int attr )
1126{ 1126{
1127 unsigned char buf[SECTOR_SIZE]; 1127 unsigned char buf[SECTOR_SIZE];
1128 int sector = file->direntry / DIR_ENTRIES_PER_SECTOR; 1128 int sector = file->direntry / DIR_ENTRIES_PER_SECTOR;
@@ -1152,6 +1152,8 @@ static int update_file_size( struct fat_file* file, int size )
1152 if (!entry[0] || entry[0] == 0xe5) 1152 if (!entry[0] || entry[0] == 0xe5)
1153 panicf("Updating size on empty dir entry %d\n", file->direntry); 1153 panicf("Updating size on empty dir entry %d\n", file->direntry);
1154 1154
1155 entry[FATDIR_ATTR] = attr & 0xFF;
1156
1155 clusptr = (short*)(entry + FATDIR_FSTCLUSHI); 1157 clusptr = (short*)(entry + FATDIR_FSTCLUSHI);
1156 *clusptr = SWAB16(file->firstcluster >> 16); 1158 *clusptr = SWAB16(file->firstcluster >> 16);
1157 1159
@@ -1264,7 +1266,7 @@ int fat_truncate(struct fat_file *file)
1264 return 0; 1266 return 0;
1265} 1267}
1266 1268
1267int fat_closewrite(struct fat_file *file, int size) 1269int fat_closewrite(struct fat_file *file, int size, int attr)
1268{ 1270{
1269 LDEBUGF("fat_closewrite(size=%d)\n",size); 1271 LDEBUGF("fat_closewrite(size=%d)\n",size);
1270 1272
@@ -1277,7 +1279,7 @@ int fat_closewrite(struct fat_file *file, int size)
1277 } 1279 }
1278 1280
1279 if (file->dircluster) 1281 if (file->dircluster)
1280 if (update_file_size(file, size) < 0) 1282 if (update_short_entry(file, size, attr) < 0)
1281 return -1; 1283 return -1;
1282 1284
1283 flush_fat(); 1285 flush_fat();
@@ -1392,7 +1394,8 @@ int fat_remove(struct fat_file* file)
1392 1394
1393int fat_rename(struct fat_file* file, 1395int fat_rename(struct fat_file* file,
1394 unsigned char* newname, 1396 unsigned char* newname,
1395 int size) 1397 int size,
1398 int attr)
1396{ 1399{
1397 int err; 1400 int err;
1398 struct fat_dir dir; 1401 struct fat_dir dir;
@@ -1414,7 +1417,7 @@ int fat_rename(struct fat_file* file,
1414 return -3; 1417 return -3;
1415 1418
1416 /* write size and cluster link */ 1419 /* write size and cluster link */
1417 err = update_file_size(&newfile, size); 1420 err = update_short_entry(&newfile, size, attr);
1418 if (err<0) 1421 if (err<0)
1419 return -4; 1422 return -4;
1420 1423
diff --git a/firmware/drivers/fat.h b/firmware/drivers/fat.h
index 8d2382f57c..6a3e5cf967 100644
--- a/firmware/drivers/fat.h
+++ b/firmware/drivers/fat.h
@@ -81,13 +81,13 @@ extern int fat_create_file(char* name,
81 struct fat_dir* dir); 81 struct fat_dir* dir);
82extern int fat_readwrite(struct fat_file *ent, int sectorcount, 82extern int fat_readwrite(struct fat_file *ent, int sectorcount,
83 void* buf, bool write ); 83 void* buf, bool write );
84extern int fat_closewrite(struct fat_file *ent, int size); 84extern int fat_closewrite(struct fat_file *ent, int size, int attr);
85extern int fat_seek(struct fat_file *ent, unsigned int sector ); 85extern int fat_seek(struct fat_file *ent, unsigned int sector );
86extern int fat_remove(struct fat_file *ent); 86extern int fat_remove(struct fat_file *ent);
87extern int fat_truncate(struct fat_file *ent); 87extern int fat_truncate(struct fat_file *ent);
88extern int fat_rename(struct fat_file* file, 88extern int fat_rename(struct fat_file* file,
89 unsigned char* newname, 89 unsigned char* newname,
90 int size); 90 int size, int attr);
91 91
92extern int fat_opendir(struct fat_dir *ent, unsigned int currdir); 92extern int fat_opendir(struct fat_dir *ent, unsigned int currdir);
93extern int fat_getnext(struct fat_dir *ent, struct fat_direntry *entry); 93extern int fat_getnext(struct fat_dir *ent, struct fat_direntry *entry);