Blob


1 #include <u.h>
2 #include <libc.h>
3 #include <bio.h>
4 #include <libsec.h>
5 #include <disk.h>
6 #include <ctype.h>
8 #include "iso9660.h"
10 #include <grp.h>
11 #include <pwd.h>
13 typedef struct Xarg Xarg;
14 struct Xarg {
15 void (*enm)(char*,char*,XDir*,void*);
16 void (*warn)(char*,void*);
17 void *arg;
18 };
20 static long numericuid(char *user);
21 static long numericgid(char *gp);
23 void
24 dirtoxdir(XDir *xd, Dir *d)
25 {
26 /* char buf[NAMELEN+1]; */
27 memset(xd, 0, sizeof *xd);
29 xd->name = atom(d->name);
30 xd->uid = atom(d->uid);
31 xd->gid = atom(d->gid);
32 xd->uidno = numericuid(d->uid);
33 xd->gidno = numericgid(d->gid);
34 xd->mode = d->mode;
35 xd->atime = d->atime;
36 xd->mtime = d->mtime;
37 xd->ctime = 0;
38 xd->length = d->length;
39 if(xd->mode & CHLINK) {
40 xd->mode |= 0777;
41 /*xd->symlink = atom(d->symlink); */
42 xd->symlink = atom("symlink"); /* XXX: rsc */
43 }
44 }
46 void
47 fdtruncate(int fd, ulong size)
48 {
49 ftruncate(fd, size);
51 return;
52 }
54 static long
55 numericuid(char *user)
56 {
57 struct passwd *pass;
58 static int warned = 0;
60 if (! (pass = getpwnam(user))) {
61 if (!warned)
62 fprint(2, "Warning: getpwnam(3) failed for \"%s\"\n", user);
63 warned = 1;
64 return 0;
65 }
67 return pass->pw_uid;
68 }
70 static long
71 numericgid(char *gp)
72 {
73 struct group *gr;
74 static int warned = 0;
76 if (! (gr = getgrnam(gp))) {
77 if (!warned)
78 fprint(2, "Warning: getgrnam(3) failed for \"%s\"\n", gp);
79 warned = 1;
80 return 0;
81 }
83 return gr->gr_gid;
84 }