Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5607076
  • 博文数量: 922
  • 博客积分: 19333
  • 博客等级: 上将
  • 技术积分: 11226
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-27 14:33
文章分类

全部博文(922)

文章存档

2023年(1)

2020年(2)

2019年(1)

2017年(1)

2016年(3)

2015年(10)

2014年(17)

2013年(49)

2012年(291)

2011年(266)

2010年(95)

2009年(54)

2008年(132)

分类: LINUX

2011-12-25 22:10:43

++++++APUE读书笔记-02UNIX标准和实现-06选项++++++

 

6、选项
================================================
 我们在前面看到了POSIX.1的选项,也给出了XSI的选项,如果我们想要写的可以移植的程序依赖这些选项,那么我们需要有一个可移植的方法来确定某个实现是否支持指定选项。
 相应前面的限制,Single UNIX Specification定义了三个方式来做到这一点:
 (a)编译期间的选项定义在中。
 (b)运行期间的和文件目录无关的选项通过sysconf函数来识别。
 (c)运行期间的和文件目录相关的选项通过pathconf或者fpathconf函数来识别。
 具体参见参考资料,这里列出一些选项:

sysconf的选项和名称参数
+-----------------------------------------------------------------------------------------------------------+
|       Name of option       |                   Description                   |       name argument        |
|----------------------------+-------------------------------------------------+----------------------------|
| _POSIX_JOB_CONTROL         | indicates whether the implementation supports   | _SC_JOB_CONTROL            |
|                            | job control                                     |                            |
|----------------------------+-------------------------------------------------+----------------------------|
| _POSIX_READER_WRITER_LOCKS | indicates whether the implementation supports   | _SC_READER_WRITER_LOCKS    |
|                            | readerwriter locks                              |                            |
|----------------------------+-------------------------------------------------+----------------------------|
| _POSIX_SAVED_IDS           | indicates whether the implementation supports   | _SC_SAVED_IDS              |
|                            | the saved set-user-ID and the saved             |                            |
|                            | set-group-ID                                    |                            |
|----------------------------+-------------------------------------------------+----------------------------|
| _POSIX_SHELL               | indicates whether the implementation supports   | _SC_SHELL                  |
|                            | the POSIX shell                                 |                            |
|----------------------------+-------------------------------------------------+----------------------------|
| _POSIX_VERSION             | indicates the POSIX.1 version                   | _SC_VERSION                |
|----------------------------+-------------------------------------------------+----------------------------|
| _XOPEN_CRYPT               | indicates whether the implementation supports   | _SC_XOPEN_CRYPT            |
|                            | the XSI encryption option group                 |                            |
|----------------------------+-------------------------------------------------+----------------------------|
| _XOPEN_LEGACY              | indicates whether the implementation supports   | _SC_XOPEN_LEGACY           |
|                            | the XSI legacy option group                     |                            |
|----------------------------+-------------------------------------------------+----------------------------|
| _XOPEN_REALTIME            | indicates whether the implementation supports   | _SC_XOPEN_REALTIME         |
|                            | the XSI real-time option group                  |                            |
|----------------------------+-------------------------------------------------+----------------------------|
| _XOPEN_REALTIME_THREADS    | indicates whether the implementation supports   | _SC_XOPEN_REALTIME_THREADS |
|                            | the XSI real-time threads option group          |                            |
|----------------------------+-------------------------------------------------+----------------------------|
| _XOPEN_VERSION             | indicates the XSI version                       | _SC_XOPEN_VERSION          |
+-----------------------------------------------------------------------------------------------------------+

fpathconf的选项和名称参数
+-----------------------------------------------------------------------------------------------------------+
|     Name of option      |                       Description                        |    name argument     |
|-------------------------+----------------------------------------------------------+----------------------|
| _POSIX_CHOWN_RESTRICTED | indicates whether use of chown is restricted             | _PC_CHOWN_RESTRICTED |
|-------------------------+----------------------------------------------------------+----------------------|
| _POSIX_NO_TRUNC         | indicates whether pathnames longer than NAME_MAX         | _PC_NO_TRUNC         |
|                         | generate an error                                        |                      |
|-------------------------+----------------------------------------------------------+----------------------|
| _POSIX_VDISABLE         | if defined, terminal special characters can be disabled  | _PC_VDISABLE         |
|                         | with this value                                          |                      |
|-------------------------+----------------------------------------------------------+----------------------|
| _POSIX_ASYNC_IO         | indicates whether asynchronous I/O can be used with the  | _PC_ASYNC_IO         |
|                         | associated file                                          |                      |
|-------------------------+----------------------------------------------------------+----------------------|
| _POSIX_PRIO_IO          | indicates whether prioritized I/O can be used with the   | _PC_PRIO_IO          |
|                         | associated file                                          |                      |
|-------------------------+----------------------------------------------------------+----------------------|
| _POSIX_SYNC_IO          | indicates whether synchronized I/O can be used with the  | _PC_SYNC_IO          |
|                         | associated file                                          |                      |
+-----------------------------------------------------------------------------------------------------------+


 下图列出一些配置选项,以及我们本文使用的四个系统中这些选项相应的值。

配置选项的例子
+-----------------------------------------------------------------------------------------------------------+
|                         |               |              |               |            Solaris 9             |
|          Limit          | FreeBSD 5.2.1 | Linux 2.4.22 | Mac OS X 10.3 |----------------------------------|
|                         |               |              |               |    UFS file    |    PCFS file    |
|                         |               |              |               |     system     |     system      |
|-------------------------+---------------+--------------+---------------+----------------+-----------------|
| _POSIX_CHOWN_RESTRICTED |             1 |            1 |             1 |              1 |               1 |
|-------------------------+---------------+--------------+---------------+----------------+-----------------|
| _POSIX_JOB_CONTROL      |             1 |            1 |             1 |              1 |               1 |
|-------------------------+---------------+--------------+---------------+----------------+-----------------|
| _POSIX_NO_TRUNC         |             1 |            1 |             1 |              1 |     unsupported |
|-------------------------+---------------+--------------+---------------+----------------+-----------------|
| _POSIX_SAVED_IDS        |   unsupported |            1 |   unsupported |              1 |               1 |
|-------------------------+---------------+--------------+---------------+----------------+-----------------|
| _POSIX_THREADS          |        200112 |       200112 |       defined |              1 |               1 |
|-------------------------+---------------+--------------+---------------+----------------+-----------------|
| _POSIX_VDISABLE         |           255 |            0 |           255 |              0 |               0 |
|-------------------------+---------------+--------------+---------------+----------------+-----------------|
| _POSIX_VERSION          |        200112 |       200112 |        198808 |         199506 |          199506 |
|-------------------------+---------------+--------------+---------------+----------------+-----------------|
| _XOPEN_UNIX             |   unsupported |            1 |     undefined |              1 |               1 |
|-------------------------+---------------+--------------+---------------+----------------+-----------------|
| _XOPEN_VERSION          |   unsupported |          500 |     undefined |              3 |               3 |
+-----------------------------------------------------------------------------------------------------------+


参考:

 

 

阅读(752) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~