Английская Википедия:/dev/zero

Материал из Онлайн справочника
Версия от 02:04, 18 декабря 2023; EducationBot (обсуждение | вклад) (Новая страница: «{{Английская Википедия/Панель перехода}} {{Confuse|Null device}} {{Short description|Special file in Unix-like operating systems}} {{Use dmy dates|date=February 2020|cs1-dates=y}} {{mono|'''/dev/zero'''}} is a special file in Unix-like operating systems that provides as many null characters (ASCII NUL, 0x00) as are read from it.<ref>{{citation|title=Advanced Linux Programming|first1=Mark|last1=Mitchell|fir...»)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)
Перейти к навигацииПерейти к поиску

Шаблон:Confuse Шаблон:Short description Шаблон:Use dmy dates Шаблон:Mono is a special file in Unix-like operating systems that provides as many null characters (ASCII NUL, 0x00) as are read from it.[1] One of the typical uses is to provide a character stream for initializing data storage.[2]

Function

Read operations from Шаблон:Mono return as many null characters (0x00) as requested in the read operation.

Unlike Шаблон:Mono, Шаблон:Mono may be used as a source, not only as a sink for data. All write operations to Шаблон:Mono succeed with no other effects. However, Шаблон:Mono is more commonly used for this purpose.

When Шаблон:Mono is memory-mapped, e.g., with mmap, to the virtual address space, it is equivalent to using anonymous memory; i.e. memory not connected to any file.

History

Шаблон:Mono was introduced in 1988 by SunOS-4.0 in order to allow a mappable BSS segment for shared libraries using anonymous memory.[3] HP-UX 8.x introduced the MAP_ANONYMOUS flag for mmap(), which maps anonymous memory directly without a need to open Шаблон:Mono.[4] Since the late 1990s, MAP_ANONYMOUS[5] or MAP_ANON are supported by most UNIX versions, removing the original purpose of Шаблон:Mono.[6]

Examples

The dd Unix utility program reads octet streams from a source to a destination, possibly performing data conversions in the process.

Destroying existing data on a file system partition or drive:

dd Шаблон:Abbr=/dev/zero Шаблон:Abbr=/dev/<destination drive or partition>

Creating a 1 MiB file, called foobar, filled with null characters:[7]

dd if=/dev/zero of=foobar count=1024 Шаблон:Abbr=1024

Note: The block size value can be given in SI (decimal) values, e.g. in GB, MB, etc. To create a Шаблон:Val file one would simply type:

dd if=/dev/zero of=foobar count=1 bs=1GB

Note: Instead of creating a real file with only zero bytes, many file systems also support the creation of sparse files which returns zeros upon reading but use less actual space.

See also

References

Шаблон:Reflist