summaryrefslogtreecommitdiffstats
path: root/bin/dd/dd.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-07-13 18:44:56 +0000
committergreen <green@FreeBSD.org>1999-07-13 18:44:56 +0000
commitac63841b827307ed6eac081c9536253d8c1fb21b (patch)
treea8f689318a437158780b279a77fc4790cfa02e2b /bin/dd/dd.c
parentf091c51c34a496d3062026be39d6948fa02b6c6e (diff)
downloadFreeBSD-src-ac63841b827307ed6eac081c9536253d8c1fb21b.zip
FreeBSD-src-ac63841b827307ed6eac081c9536253d8c1fb21b.tar.gz
Implement seekability for disk devices (not just regular files).
Also, fix pos_out() to do the same checks pos_in() did. Done for: jdp, luigi, the good of the world
Diffstat (limited to 'bin/dd/dd.c')
-rw-r--r--bin/dd/dd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/dd/dd.c b/bin/dd/dd.c
index b817b00..b6e0ebb 100644
--- a/bin/dd/dd.c
+++ b/bin/dd/dd.c
@@ -46,11 +46,12 @@ static char const copyright[] =
static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
#endif
static const char rcsid[] =
- "$Id: dd.c,v 1.16 1999/04/25 21:13:33 imp Exp $";
+ "$Id: dd.c,v 1.18 1999/06/20 14:58:51 green Exp $";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
+#include <sys/diskslice.h>
#include <sys/mtio.h>
#include <ctype.h>
@@ -224,10 +225,14 @@ getfdtype(io)
IO *io;
{
struct mtget mt;
+ struct diskslices ds;
struct stat sb;
if (fstat(io->fd, &sb))
err(1, "%s", io->name);
+ if ((S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) &&
+ ioctl(io->fd, DIOCGSLICEINFO, &ds) != -1)
+ io->flags |= ISDISK;
if (S_ISCHR(sb.st_mode))
io->flags |= ioctl(io->fd, MTIOCGET, &mt) ? ISCHR : ISTAPE;
else if (lseek(io->fd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE)
OpenPOWER on IntegriCloud