Zeros and ones
keramida at ceid.upatras.gr
Fri May 2 18:28:09 PDT 2003
On 2003-05-02 18:07, Joshua Oreman <oremanj at www.get-linux.org> wrote:
>On Fri, May 02, 2003 at 05:50:45PM -0700 or thereabouts, Kevin Stevens seemed to write:
>>> On Fri, May 02, 2003 at 07:53:40PM -0400, Jerry McAllister wrote:
>>>> This should be easy, but short of writing something specific to do it,
>>>> I am not getting my head around how.
>>>> It is easy and convenient to use /dev/zero to write out a number of
>>>> zero bytes to somewhere - as in:
>>>> But, I would like to write all ones - as in 0xff or maybe some
>>>> other pattern - as if there was a /dev/one also.
>> I absolutely can't believe it. At the exact time Jerry was struggling
>> with this, I was working on *exactly* the same issue. Couldn't have
>> phrased his question any better - I was actually looking in /dev for a
>> "one" device!
>> My way of resolving the problem, BTW, was to create a pure white bitmap in
>> PhotoShop and trim it to the size I needed with "head". Different ways to
>> skin the cat! ;)
> Yet another (theoretical) way to do it:
> Create a 'rept' device driver in the kernel that uses ioctl() to set the
> bytes to spew out. Base 'zero' on that. Could have a few uses... not :-)
Not. We have tr(1) already.
dd if=/dev/zero | tr '\000' '\xxx' >filename
is the canonical way of creating ANY type of file that contains \xxx
bytes, and it doesn't require special kernel hacking skills to work on
any number of platforms :-)
More information about the freebsd-questions