Beispiel #1
0
/**
 *
 * uid2utf8: converts a uid to a utf8 string descriptor.
 *
 * Converts a uid to a utf8 string descriptor.
 *
 * @param uid     [IN]  the input uid
 * @param utf8str [OUT] computed UTF8 string descriptor
 *
 * @return the length of the utf8 buffer if succesfull, -1 if failed
 *
 */
int uid2utf8(uid_t uid, utf8string * utf8str)
{
  char buff[NFS4_MAX_DOMAIN_LEN];
  unsigned int len = 0;

  if(uid2str(uid, buff) == -1)
    return -1;

  len = strlen(buff);

  /* A matching uid was found, now do the conversion to utf8 */
  if((utf8str->utf8string_val = (char *)Mem_Alloc_Label(len, "uid2utf8")) == NULL)
    return -1;
  else
    utf8str->utf8string_len = len;

  return str2utf8(buff, utf8str);

}                               /* uid2utf8 */
Beispiel #2
0
void PosixStat2EntryAttr( struct stat *p_inode, attr_set_t * p_attr_set, int size_info )
{
    ATTR_MASK_SET( p_attr_set, owner );
    uid2str( p_inode->st_uid, ATTR( p_attr_set, owner ) );

    ATTR_MASK_SET( p_attr_set, gr_name );
    gid2str( p_inode->st_gid, ATTR( p_attr_set, gr_name ) );

    if ( size_info )
    {
        ATTR_MASK_SET( p_attr_set, size );
        ATTR( p_attr_set, size ) = p_inode->st_size;

        ATTR_MASK_SET( p_attr_set, blocks );
        ATTR( p_attr_set, blocks ) = p_inode->st_blocks;

#ifdef ATTR_INDEX_blksize
        ATTR_MASK_SET( p_attr_set, blksize );
        ATTR( p_attr_set, blksize ) = p_inode->st_blksize;
#endif
    }

    ATTR_MASK_SET( p_attr_set, last_access );
    ATTR( p_attr_set, last_access ) =
        MAX3( p_inode->st_atime, p_inode->st_mtime, p_inode->st_ctime );

    ATTR_MASK_SET( p_attr_set, last_mod );
    /* @TODO is this really what we want? */
#if defined(_SHERPA) || defined(_HSM_LITE)
    ATTR( p_attr_set, last_mod ) = p_inode->st_mtime;
#else
    ATTR( p_attr_set, last_mod ) = MAX2( p_inode->st_mtime, p_inode->st_ctime );
#endif

#ifdef ATTR_INDEX_type
    if ( S_ISREG( p_inode->st_mode ) )
    {
        ATTR_MASK_SET( p_attr_set, type );
        strcpy( ATTR( p_attr_set, type ), STR_TYPE_FILE );
    }
    else if ( S_ISDIR( p_inode->st_mode ) )
    {
        ATTR_MASK_SET( p_attr_set, type );
        strcpy( ATTR( p_attr_set, type ), STR_TYPE_DIR );
    }
    else if ( S_ISCHR( p_inode->st_mode ) )
    {
        ATTR_MASK_SET( p_attr_set, type );
        strcpy( ATTR( p_attr_set, type ), STR_TYPE_CHR );
    }
    else if ( S_ISBLK( p_inode->st_mode ) )
    {
        ATTR_MASK_SET( p_attr_set, type );
        strcpy( ATTR( p_attr_set, type ), STR_TYPE_BLK );
    }
    else if ( S_ISFIFO( p_inode->st_mode ) )
    {
        ATTR_MASK_SET( p_attr_set, type );
        strcpy( ATTR( p_attr_set, type ), STR_TYPE_FIFO );
    }
    else if ( S_ISLNK( p_inode->st_mode ) )
    {
        ATTR_MASK_SET( p_attr_set, type );
        strcpy( ATTR( p_attr_set, type ), STR_TYPE_LINK );
    }
    else if ( S_ISSOCK( p_inode->st_mode ) )
    {
        ATTR_MASK_SET( p_attr_set, type );
        strcpy( ATTR( p_attr_set, type ), STR_TYPE_SOCK );
    }
#endif

#ifdef ATTR_INDEX_nlink
    ATTR_MASK_SET( p_attr_set, nlink );
    ATTR( p_attr_set, nlink ) = p_inode->st_nlink;
#endif
}