示例#1
0
void ls_stat(char *dirname, char *entryname)
{
	char *tmp_pathname;
	struct stat buf;
	char mode[11];

	tmp_pathname = strdup(dirname);
	if(strcmp(dirname, "/") != 0)
		tmp_pathname = xstrcat(tmp_pathname, "/");
	tmp_pathname = xstrcat(tmp_pathname, entryname);

	if(stat(tmp_pathname, &buf) < 0){
		perror("ERROR: stat");
		exit(1);
	}

	get_mode(&buf, mode);
	printf("%s	", mode);
	printf("%d	", buf.st_nlink);

	printf("%s	", uid2name(buf.st_uid));
	printf("%s	", gid2name(buf.st_gid));
	printf("%ld	", buf.st_size);
	printf("%.12s	", ctime(&buf.st_mtime)+4);
	printf("%s\n", entryname);
}
示例#2
0
/**
 *
 * gid2ustr: convert a gid to a string.
 *
 * Convert a gidonvert a gid to a string. to a string.
 *
 * @param gid [IN]  the input gid
 * @param str [OUT] computed string
 *
 * @return the length of the utf8 buffer if succesfull, -1 if failed
 *
 */
int gid2str(gid_t gid, char *str)
{
  char buffer[NFS4_MAX_DOMAIN_LEN];
  gid_t local_gid = gid;
  int rc;

  if(gid2name(buffer, &local_gid) == 0)
    return -1;

#ifndef _USE_NFSIDMAP
  rc = sprintf(str, "%s@%s", buffer, nfs_param.nfsv4_param.domainname);
#else
  rc = sprintf(str, "%s", buffer);
#endif

  LogDebug(COMPONENT_IDMAPPER,
           "gid2str %d returning %s",
           gid, str);

  return rc;
}                               /* gid2str */