linux struct utsname 结构详解是utsname 函数使用说明
来源:互联网 发布:物流仿真模拟软件 编辑:程序博客网 时间:2024/06/08 16:00
【uname系统调用】
功能描述:
获取当前内核名称和其它信息。
用法:
#include <sys/utsname.h>
extern int uname (struct utsname *__name) __THROW;
参数:
__name:指向存放系统信息的缓冲区,原型如下
struct utsname
{ char sysname[_UTSNAME_SYSNAME_LENGTH];//当前操作系统名
char nodename[_UTSNAME_NODENAME_LENGTH];//网络上的名称
char release[_UTSNAME_RELEASE_LENGTH];//当前发布级别
char version[_UTSNAME_VERSION_LENGTH];//当前发布版本
char machine[_UTSNAME_MACHINE_LENGTH];//当前硬件体系类型
#if _UTSNAME_DOMAIN_LENGTH - 0
/* Name of the domain of this node on the network. */
# ifdef __USE_GNU
char domainname[_UTSNAME_DOMAIN_LENGTH]; //当前域名
# else
char __domainname[_UTSNAME_DOMAIN_LENGTH];
# endif
#endif
};
返回说明:
成功执行时,返回0。失败返回-1,errno被设为EFAULT,表示buf无效。
关于uname的具体用法可以使用“man uname”来查看。
实例如下:
#include <sys/utsname.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
struct utsname testbuff;
int fb=0;
fb=uname(&testbuff);
if(fb<0)
{
perror("uname");
return 0;
}else
{
printf(" sysname:%s/n nodename:%s/n release:%s/n version:%s/n machine:%s/n /n ",/
testbuff.sysname,/
testbuff.nodename,/
testbuff.release,/
testbuff.version,/
testbuff.machine);
#if _UTSNAME_DOMAIN_LENGTH - 0
# ifdef __USE_GNU
printf(" domainame:%s/n ",testbuff.domainname);
//char domainname[_UTSNAME_DOMAIN_LENGTH]; //当前域名
# else
printf(" __domainame:%s/n ",testbuff.__domainname);
//char __domainname[_UTSNAME_DOMAIN_LENGTH];
# endif
#endif
}
return 0;
}
本文出自 51CTO.COM技术博客
功能描述:
获取当前内核名称和其它信息。
用法:
#include <sys/utsname.h>
extern int uname (struct utsname *__name) __THROW;
参数:
__name:指向存放系统信息的缓冲区,原型如下
struct utsname
{ char sysname[_UTSNAME_SYSNAME_LENGTH];//当前操作系统名
char nodename[_UTSNAME_NODENAME_LENGTH];//网络上的名称
char release[_UTSNAME_RELEASE_LENGTH];//当前发布级别
char version[_UTSNAME_VERSION_LENGTH];//当前发布版本
char machine[_UTSNAME_MACHINE_LENGTH];//当前硬件体系类型
#if _UTSNAME_DOMAIN_LENGTH - 0
/* Name of the domain of this node on the network. */
# ifdef __USE_GNU
char domainname[_UTSNAME_DOMAIN_LENGTH]; //当前域名
# else
char __domainname[_UTSNAME_DOMAIN_LENGTH];
# endif
#endif
};
返回说明:
成功执行时,返回0。失败返回-1,errno被设为EFAULT,表示buf无效。
关于uname的具体用法可以使用“man uname”来查看。
实例如下:
#include <sys/utsname.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
struct utsname testbuff;
int fb=0;
fb=uname(&testbuff);
if(fb<0)
{
perror("uname");
return 0;
}else
{
printf(" sysname:%s/n nodename:%s/n release:%s/n version:%s/n machine:%s/n /n ",/
testbuff.sysname,/
testbuff.nodename,/
testbuff.release,/
testbuff.version,/
testbuff.machine);
#if _UTSNAME_DOMAIN_LENGTH - 0
# ifdef __USE_GNU
printf(" domainame:%s/n ",testbuff.domainname);
//char domainname[_UTSNAME_DOMAIN_LENGTH]; //当前域名
# else
printf(" __domainame:%s/n ",testbuff.__domainname);
//char __domainname[_UTSNAME_DOMAIN_LENGTH];
# endif
#endif
}
return 0;
}
本文出自 51CTO.COM技术博客
- linux struct utsname 结构详解是utsname 函数使用说明
- linux struct utsname 结构详解是utsname 函数使用说明
- linux struct utsname 结构详解是utsname 函数使用说明
- linux struct utsname 结构详解
- 【获取iOS设备类型与系统版本号】结构体utsname与uname方法的使用
- linux struct input_event结构体详解
- 代码记录--代码获取设备型号和系统版本(utsname)
- struct socket 结构详解
- struct protoent函数结构
- struct security_operations {}函数结构
- linux系统中struct timeval结构体、struct timezone结构体以及gettimeofday函数
- linux struct stat 结构
- Linux struct inode结构
- linux struct stat 结构
- Linux struct file结构
- linux struct stat 结构
- Linux struct file结构
- linux struct file结构
- C中可变参数宏实现调试打印
- 80后的我们拿什么养活自己和家人
- web developer tips (74):在 Visual Studio 2008设计器里添加或移除AJAX Extenders
- linux定时执行crontab使用方法
- 解决is not in the sudoers file. This incident will be reported
- linux struct utsname 结构详解是utsname 函数使用说明
- 实现GridView项的全选 集体处理项
- 通用baseDAL类(2)
- printk 使用方法
- UVa 146 ID Codes
- 设计模式学习总结
- mysql中查询第几行到第几行及查询第一条数据
- 日语假名的输入
- 继Twitter之后 Digg用NoSQL替代MySQL