Skip to content

Commit 99fa936

Browse files
committed
Merge tag 'affs-6.14-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull affs fixes from David Sterba: "Two fixes from Simon Tatham. They're real bugfixes for problems with OFS floppy disks created on linux and then read in the emulated Workbench environment" * tag 'affs-6.14-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: affs: don't write overlarge OFS data block size fields affs: generate OFS sequence numbers starting at 1
2 parents d9a9c94 + 011ea74 commit 99fa936

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fs/affs/file.c

Lines changed: 5 additions & 4 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);
@@ -724,7 +724,8 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
724724
tmp = min(bsize - boff, to - from);
725725
BUG_ON(boff + tmp > bsize || tmp > bsize);
726726
memcpy(AFFS_DATA(bh) + boff, data + from, tmp);
727-
be32_add_cpu(&AFFS_DATA_HEAD(bh)->size, tmp);
727+
AFFS_DATA_HEAD(bh)->size = cpu_to_be32(
728+
max(boff + tmp, be32_to_cpu(AFFS_DATA_HEAD(bh)->size)));
728729
affs_fix_checksum(sb, bh);
729730
mark_buffer_dirty_inode(bh, inode);
730731
written += tmp;
@@ -746,7 +747,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
746747
if (buffer_new(bh)) {
747748
AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);
748749
AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino);
749-
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx);
750+
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx + 1);
750751
AFFS_DATA_HEAD(bh)->size = cpu_to_be32(bsize);
751752
AFFS_DATA_HEAD(bh)->next = 0;
752753
bh->b_state &= ~(1UL << BH_New);
@@ -780,7 +781,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
780781
if (buffer_new(bh)) {
781782
AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);
782783
AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino);
783-
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx);
784+
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx + 1);
784785
AFFS_DATA_HEAD(bh)->size = cpu_to_be32(tmp);
785786
AFFS_DATA_HEAD(bh)->next = 0;
786787
bh->b_state &= ~(1UL << BH_New);

0 commit comments

Comments
 (0)