public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: 2.4.0-test10 truncate() change broke `dd'
@ 2000-11-16 11:32 Mikael Pettersson
  2000-11-16 11:53 ` Alexander Viro
  0 siblings, 1 reply; 6+ messages in thread
From: Mikael Pettersson @ 2000-11-16 11:32 UTC (permalink / raw)
  To: mikpe, viro; +Cc: aeb, linux-kernel

On Thu, 16 Nov 2000, Alexander Viro wrote:

> And what kind of meaning would you assign to truncate on floppy?

On a block or char device, truncate == lseek seems reasonable.

My guess is that dd uses ftruncate because that's correct for
regular files and has happened to also work (as an alias for
lseek) for devices.

> Use conv=notrunc.

I didn't know about notrunc. Yet another GNU invention?

/Mikael
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 6+ messages in thread
* 2.4.0-test10 truncate() change broke `dd'
@ 2000-11-16  0:58 Mikael Pettersson
  2000-11-16  8:02 ` Alexander Viro
  0 siblings, 1 reply; 6+ messages in thread
From: Mikael Pettersson @ 2000-11-16  0:58 UTC (permalink / raw)
  To: linux-kernel

2.4.0-test10 broke `dd' for block devices, due to the following
change to do_sys_truncate & do_sys_ftruncate:

diff -u --recursive --new-file v2.4.0-test9/linux/fs/open.c linux/fs/open.c
--- v2.4.0-test9/linux/fs/open.c	Sun Oct  8 10:50:33 2000
+++ linux/fs/open.c	Thu Oct 26 08:11:21 2000
@@ -103,7 +103,7 @@
 	inode = nd.dentry->d_inode;
 
 	error = -EACCES;
-	if (S_ISDIR(inode->i_mode))
+	if (!S_ISREG(inode->i_mode))
 		goto dput_and_out;
 
 	error = permission(inode,MAY_WRITE);
@@ -164,7 +164,7 @@
 	dentry = file->f_dentry;
 	inode = dentry->d_inode;
 	error = -EACCES;
-	if (S_ISDIR(inode->i_mode) || !(file->f_mode & FMODE_WRITE))
+	if (!S_ISREG(inode->i_mode) || !(file->f_mode & FMODE_WRITE))
 		goto out_putf;
 	error = -EPERM;
 	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))

I noticed because I needed to build a boot floppy with an
initial ram disk under 2.4.0-test11pre5. The standard recipe
(Documentation/ramdisk.txt) basically goes:
- dd if=bzImage of=/dev/fd0 bs=1k
  notice how many blocks dd reported (NNN)
- dd if=ram_image of=/dev/fd0 bs=1k seek=NNN
dd implements the seek=NNN option by calling ftruncate() before
starting the write. This is where 2.4.0-test10 breaks, since
ftruncate on a block device now provokes an EACCES error.

Maybe `dd' is buggy and should use lseek() instead, but this has
apparently worked for a long time.

Does anyone know the reason for the S_ISDIR -> !S_ISREG change in test10?

/Mikael
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-11-17 17:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-16 11:32 2.4.0-test10 truncate() change broke `dd' Mikael Pettersson
2000-11-16 11:53 ` Alexander Viro
2000-11-16 14:44   ` Andries Brouwer
  -- strict thread matches above, loose matches on Subject: below --
2000-11-16  0:58 Mikael Pettersson
2000-11-16  8:02 ` Alexander Viro
2000-11-17 17:16   ` Andries Brouwer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox