Skip to contentSkip to conversation

: ufs: fix symlink creation on ufs2

PATCH In review Evgeniy Dushistov 4 participants 4 messages Jan 2, 2008 – Jan 10, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : ufs: fix symlink creation on ufs2

If create symlink on UFS2 filesystem under Linux,
it looks wrong under other OSes, because of max symlink length field was not initialized properly, and data blocks were not used to save short symlink names.

---

fs/ufs/super.c +4 -2
index 0072cb3..14605c0 100644
@@ -131,6 +131,8 @@ static void ufs_print_super_stuff(struct super_block *sb,
 		printk(KERN_INFO"  cs_nffree(Num of free frags): %llu\n",
 		       (unsigned long long)
 		       fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree));
+		printk(KERN_INFO"  fs_maxsymlinklen: %u\n",
+		       usb3->fs_un2.fs_44.fs_maxsymlinklen);
 	} else {
 		printk(" sblkno:      %u\n", fs32_to_cpu(sb, usb1->fs_sblkno));
 		printk(" cblkno:      %u\n", fs32_to_cpu(sb, usb1->fs_cblkno));
@@ -1060,8 +1062,8 @@ magic_found:
 	uspi->s_bpf = uspi->s_fsize << 3;
 	uspi->s_bpfshift = uspi->s_fshift + 3;
 	uspi->s_bpfmask = uspi->s_bpf - 1;
-	if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) ==
-	    UFS_MOUNT_UFSTYPE_44BSD)
+	if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_44BSD ||
+	    (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_UFS2)
 		uspi->s_maxsymlinklen =
 		    fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen);
 
Signature · 1 line
/Evgeniy
#1 lore raw
Quoted 15 lines · On Wed, 2 Jan 2008 23:47:04 +0300 Evgeniy Dushistov <[email protected]> wrote:

If create symlink on UFS2 filesystem under Linux,
it looks wrong under other OSes, because of max symlink length field was not initialized properly, and data blocks were not used to save short symlink names.

---

fs/ufs/super.c +0 -0
index 0072cb3..14605c0 100644

fs/ufs/super.c static void ufs_print_super_stuff(struct super_block *sb, · line 135

Quoted 5 lines
fs/ufs/super.c +2 -0
@@ -131,6 +131,8 @@ static void ufs_print_super_stuff(struct super_block *sb,
 		printk(KERN_INFO"  cs_nffree(Num of free frags): %llu\n",
 		       (unsigned long long)
 		       fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree));
+		printk(KERN_INFO"  fs_maxsymlinklen: %u\n",
+		       usb3->fs_un2.fs_44.fs_maxsymlinklen);

I assume this needs conversion via fs32_to_cpu() before we print it.

Quoted 14 lines
fs/ufs/super.c +2 -2
 	} else {
 		printk(" sblkno:      %u\n", fs32_to_cpu(sb, usb1->fs_sblkno));
 		printk(" cblkno:      %u\n", fs32_to_cpu(sb, usb1->fs_cblkno));
@@ -1060,8 +1062,8 @@ magic_found:
 	uspi->s_bpf = uspi->s_fsize << 3;
 	uspi->s_bpfshift = uspi->s_fshift + 3;
 	uspi->s_bpfmask = uspi->s_bpf - 1;
-	if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) ==
-	    UFS_MOUNT_UFSTYPE_44BSD)
+	if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_44BSD ||
+	    (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_UFS2)
 		uspi->s_maxsymlinklen =
 		    fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen);
 
#2 lore raw
Quoted 9 lines · Andrew Morton

fs/ufs/super.c static void ufs_print_super_stuff(struct super_block *sb, · line 135

Quoted 7 lines

+++ b/fs/ufs/super.c

fs/ufs/super.c +2 -0
@@ -131,6 +131,8 @@ static void ufs_print_super_stuff(struct super_block *sb,
 		printk(KERN_INFO"  cs_nffree(Num of free frags): %llu\n",
 		       (unsigned long long)
 		       fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree));
+		printk(KERN_INFO"  fs_maxsymlinklen: %u\n",
+		       usb3->fs_un2.fs_44.fs_maxsymlinklen);

I assume this needs conversion via fs32_to_cpu() before we print it.

Yes, it does. I wish people would run sparse before submitting patches :P

#3 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 9 lines · Andrew Morton

fs/ufs/super.c static void ufs_print_super_stuff(struct super_block *sb, · line 135

Quoted 7 lines

+++ b/fs/ufs/super.c

fs/ufs/super.c +2 -0
@@ -131,6 +131,8 @@ static void ufs_print_super_stuff(struct super_block *sb,
 		printk(KERN_INFO"  cs_nffree(Num of free frags): %llu\n",
 		       (unsigned long long)
 		       fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree));
+		printk(KERN_INFO"  fs_maxsymlinklen: %u\n",
+		       usb3->fs_un2.fs_44.fs_maxsymlinklen);

I assume this needs conversion via fs32_to_cpu() before we print it.

Quoted 1 line

Yes, it does. I wish people would run sparse before submitting patches :P

sparse wouldn't have helped it in the current state. The thing is, it doesn't understand printf-style formats. We probably ought to implement that - would have a benefit of being able to get rid of gcc stupidity in that area and actually define conversion specifiers of our own for things like u64, dma_addr_t, etc. without having gcc scream at us...