Example #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);
}
Example #2
0
/**
 *
 * uid2ustr: convert a uid to a string.
 *
 * Convert a gidonvert a uid to a string. to a string.
 *
 * @param uid [IN]  the input gid
 * @param str [OUT] computed string
 *
 * @return the length of the utf8 buffer if succesfull, -1 if failed
 *
 */
int uid2str(uid_t uid, char *str)
{
  char buffer[NFS4_MAX_DOMAIN_LEN];
  uid_t local_uid = uid;
  int rc;

  if(uid2name(buffer, &local_uid) == 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,
           "uid2str %d returning %s",
           uid, str);

  return rc;
}                               /* uid2utf8 */