[cs631apue] segfail when using getpwuid
    Jan Schaumann 
    jschauma at stevens.edu
       
    Sun Oct  5 21:57:25 EDT 2014
    
    
  
Jin Sun <jsun6 at stevens.edu> wrote:
> Sorry I miss type the uid and gid
Still note that it's possible for a file to have an st_uid that
getpwuid(3) cannot map to an entry (and in which case it would return
NULL).  *Any function that _can_ fail, _will_ fail.  Check all return
codes before using the result.*
> And how to get the actual file size? I try to use st_block * st_blksize but
> the result is wired.
st_size contains the file size, in bytes.
st_blocks contains the number of blocks allocated for the file, but not
all files' sizes are necessarily evenly disibile by the block size.
-Jan
    
    
More information about the cs631apue
mailing list