~ubuntu-branches/ubuntu/jaunty/9base/jaunty

« back to all changes in this revision

Viewing changes to lib9/dirstat.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2006-01-25 15:33:00 UTC
  • Revision ID: james.westby@ubuntu.com-20060125153300-6hh4p9wx8iqqply5
Tags: upstream-2
ImportĀ upstreamĀ versionĀ 2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <u.h>
 
2
#define NOPLAN9DEFINES
 
3
#include <libc.h>
 
4
 
 
5
#include <sys/stat.h>
 
6
 
 
7
extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*);
 
8
 
 
9
Dir*
 
10
dirstat(char *file)
 
11
{
 
12
        struct stat lst;
 
13
        struct stat st;
 
14
        int nstr;
 
15
        Dir *d;
 
16
        char *str;
 
17
 
 
18
        if(lstat(file, &lst) < 0)
 
19
                return nil;
 
20
        st = lst;
 
21
        if((lst.st_mode&S_IFMT) == S_IFLNK)
 
22
                stat(file, &st);
 
23
 
 
24
        nstr = _p9dir(&lst, &st, file, nil, nil, nil);
 
25
        d = mallocz(sizeof(Dir)+nstr, 1);
 
26
        if(d == nil)
 
27
                return nil;
 
28
        str = (char*)&d[1];
 
29
        _p9dir(&lst, &st, file, d, &str, str+nstr);
 
30
        return d;
 
31
}
 
32