avatar
G*n
1
Can you tell me how to get the User name and Group
name of a file in the UNIX? I can only get the User ID
and Group ID by calling 'stat' or 'lstat'.
Thank yo
avatar
g*e
2
What Unix system you use?
In Solaris:
ls -l

【在 G****n 的大作中提到】
: Can you tell me how to get the User name and Group
: name of a file in the UNIX? I can only get the User ID
: and Group ID by calling 'stat' or 'lstat'.
: Thank yo

avatar
s*d
3
I think he is talking about system calls.

【在 g****e 的大作中提到】
: What Unix system you use?
: In Solaris:
: ls -l

avatar
o*a
4

#include
#include
#include
...................
struct passwd * uptr = getpwuid(uid_t uid);
struct group * gptr = getgrgid(gid_t gid);
printf("%s", uptr->pw_name );
printf("%s", gptr->gr_name);

【在 G****n 的大作中提到】
: Can you tell me how to get the User name and Group
: name of a file in the UNIX? I can only get the User ID
: and Group ID by calling 'stat' or 'lstat'.
: Thank yo

avatar
G*n
5
Yes. Now I can use function getpwuid() to get the
owner of file, but how to get the group name?

【在 s*****d 的大作中提到】
: I think he is talking about system calls.
avatar
G*n
6
Thank you very much!

【在 o**a 的大作中提到】
:
: #include
: #include
: #include
: ...................
: struct passwd * uptr = getpwuid(uid_t uid);
: struct group * gptr = getgrgid(gid_t gid);
: printf("%s", uptr->pw_name );
: printf("%s", gptr->gr_name);

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。