G****n 发帖数: 618 | 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 |
g****e 发帖数: 65 | 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
|
s*****d 发帖数: 258 | 3 I think he is talking about system calls.
【在 g****e 的大作中提到】 : What Unix system you use? : In Solaris: : ls -l
|
o**a 发帖数: 86 | 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
|
G****n 发帖数: 618 | 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.
|
G****n 发帖数: 618 | 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);
|