Why does the Linux Open system call not need a buffer size parameter for the path?

后端 未结 1 1529
囚心锁ツ
囚心锁ツ 2021-01-28 02:10

Why does the open system call not need a buffer size parameter like the write system call does?

How do these two system calls treat their strin

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-28 02:58

    UNIX was developed as an operating system for programs written in assembly, later for programs written in C. In the assembly convention the UNIX team uses and later in C, strings are terminated with NUL bytes. Thus it is only natural to use the same convention when talking to the operating system. Linus copied the UNIX API when designing Linux, so that's why it has the same design. No functionality is lost by terminating strings with NUL as NUL bytes are not allowed to appear in paths or other identifiers.

    A write call writes arbitrary binary data to a file. This data is not necessarily text thus using the string convention doesn't make much sense.

    0 讨论(0)
提交回复
热议问题