diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/disk/9660/unix.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/disk/9660/unix.c')
-rwxr-xr-x | sys/src/cmd/disk/9660/unix.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/sys/src/cmd/disk/9660/unix.c b/sys/src/cmd/disk/9660/unix.c new file mode 100755 index 000000000..942dac85d --- /dev/null +++ b/sys/src/cmd/disk/9660/unix.c @@ -0,0 +1,83 @@ +#include <u.h> +#include <libc.h> +#include <bio.h> +#include <libsec.h> +#include <libproto.h> +#include <ctype.h> + +#include "iso9660.h" + +#include <grp.h> +#include <pwd.h> + +typedef struct Xarg Xarg; +struct Xarg { + void (*enm)(char*,char*,XDir*,void*); + void (*warn)(char*,void*); + void *arg; +}; + +static long numericuid(char *user); +static long numericgid(char *gp); + +void +dirtoxdir(XDir *xd, Dir *d) +{ + // char buf[NAMELEN+1]; + memset(xd, 0, sizeof *xd); + + xd->name = atom(d->name); + xd->uid = atom(d->uid); + xd->gid = atom(d->gid); + xd->uidno = numericuid(d->uid); + xd->gidno = numericgid(d->gid); + xd->mode = d->mode; + xd->atime = d->atime; + xd->mtime = d->mtime; + xd->ctime = 0; + xd->length = d->length; + if(xd->mode & CHLINK) { + xd->mode |= 0777; + xd->symlink = atom(d->symlink); + } +}; + +void +fdtruncate(int fd, ulong size) +{ + ftruncate(fd, size); + + return; +} + +static long +numericuid(char *user) +{ + struct passwd *pass; + static int warned = 0; + + if (! (pass = getpwnam(user))) { + if (!warned) + fprint(2, "Warning: getpwnam(3) failed for \"%s\"\n", user); + warned = 1; + return 0; + } + + return pass->pw_uid; +} + +static long +numericgid(char *gp) +{ + struct group *gr; + static int warned = 0; + + if (! (gr = getgrnam(gp))) { + if (!warned) + fprint(2, "Warning: getgrnam(3) failed for \"%s\"\n", gp); + warned = 1; + return 0; + } + + return gr->gr_gid; +} |