Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Sep 2006 16:50:19 +0400
From:      Ruslan Ermilov <ru@freebsd.org>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        freebsd-bugs@freebsd.org, Helmut Schellong <var@schellong.biz>
Subject:   Re: bin/103845: sha256 /dev/acd0  returns immediately
Message-ID:  <20060930125019.GB38718@rambler-co.ru>
In-Reply-To: <20060930205828.M926@epsplex.bde.org>
References:  <200609300624.k8U6O9TM017192@www.freebsd.org> <20060930205828.M926@epsplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--uQr8t48UFsdbeI+V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Sep 30, 2006 at 09:51:45PM +1000, Bruce Evans wrote:
> On Sat, 30 Sep 2006, Helmut Schellong wrote:
>=20
> >>Description:
> >sha256 /dev/acd0  returns *immediately*
> >with a wrong checksum.
> >
> >CD content is BETA1-disc1.
> >
> >dd if=3D/dev/acd0 of=3D/usr/z bs=3D4b; sha256 /usr/z; rm /usr/z
> >works fine.
>=20
> md5(1) and friends haven't worked for files specified on the command
> line since 2001.
>=20
I think you meant to say "for device special files".

$ md5 /bin/cat /bin/cp
MD5 (/bin/cat) =3D 51c9c34f1d2db0f73d043929556a687b
MD5 (/bin/cp) =3D b456419be246512f9fe3ac1cd4219331
$ cat /bin/cat | md5
51c9c34f1d2db0f73d043929556a687b
$ cat /bin/cp | md5
b456419be246512f9fe3ac1cd4219331

> At least for md5, this is due to a bug in libmd.
> MDXFileChunk() has been used to implement MDXFile() since 2001, but
> MDXFileChunk() cannot be used for this since it assumes that the file
> is a regular file (or perhaps a symlink) so that st_size is valid and
> the file is seekable.
>=20
> One workaround is to run md5 on 1 file at a time and not specify the
> file on the command line.  "md5 </dev/acd0" works because it uses the
> "filter" cases which doesn't go near the buggy code.
>=20
> Another workaround is to use a pipeline: "cat /dev/acd0 | md5".  For
> pipes, it is essential that md5 act as a filter.  However, the previous
> workaround is better if you don't start with a pipe.
>=20
> The workaround can also be used backwards to break the case where the
> file or pipe is already open: "md5 /dev/stdin </dev/acd0" gives the
> checksum of an empty file.


Cheers,
--=20
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer

--uQr8t48UFsdbeI+V
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFHmgLqRfpzJluFF4RAssqAJ0eJapJF2SUQ9kR+zvCz5p/7hHPaQCfR9ti
nvZ7S7822k8J0VO5r5Tgxoo=
=ANf2
-----END PGP SIGNATURE-----

--uQr8t48UFsdbeI+V--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060930125019.GB38718>