Skip to content

Commit 44d16a1

Browse files
sgtathamaloktiwa
authored andcommitted
affs: generate OFS sequence numbers starting at 1
[ Upstream commit e4cf8ec ] If I write a file to an OFS floppy image, and try to read it back on an emulated Amiga running Workbench 1.3, the Amiga reports a disk error trying to read the file. (That is, it's unable to read it _at all_, even to copy it to the NIL: device. It isn't a matter of getting the wrong data and being unable to parse the file format.) This is because the 'sequence number' field in the OFS data block header is supposed to be based at 1, but affs writes it based at 0. All three locations changed by this patch were setting the sequence number to a variable 'bidx' which was previously obtained by dividing a file position by bsize, so bidx will naturally use 0 for the first block. Therefore all three should add 1 to that value before writing it into the sequence number field. With this change, the Amiga successfully reads the file. For data block reference: https://wiki.osdev.org/FFS_(Amiga) Signed-off-by: Simon Tatham <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 739499e146320eec6dc3ae27f993e22955c0e932) Signed-off-by: Alok Tiwari <[email protected]>
1 parent 5454819 commit 44d16a1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/affs/file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
596596
BUG_ON(tmp > bsize);
597597
AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);
598598
AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino);
599-
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx);
599+
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx + 1);
600600
AFFS_DATA_HEAD(bh)->size = cpu_to_be32(tmp);
601601
affs_fix_checksum(sb, bh);
602602
bh->b_state &= ~(1UL << BH_New);
@@ -746,7 +746,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
746746
if (buffer_new(bh)) {
747747
AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);
748748
AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino);
749-
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx);
749+
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx + 1);
750750
AFFS_DATA_HEAD(bh)->size = cpu_to_be32(bsize);
751751
AFFS_DATA_HEAD(bh)->next = 0;
752752
bh->b_state &= ~(1UL << BH_New);
@@ -780,7 +780,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
780780
if (buffer_new(bh)) {
781781
AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);
782782
AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino);
783-
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx);
783+
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx + 1);
784784
AFFS_DATA_HEAD(bh)->size = cpu_to_be32(tmp);
785785
AFFS_DATA_HEAD(bh)->next = 0;
786786
bh->b_state &= ~(1UL << BH_New);

0 commit comments

Comments
 (0)