diff options
author | wkj <devnull@localhost> | 2004-06-17 01:47:21 +0000 |
---|---|---|
committer | wkj <devnull@localhost> | 2004-06-17 01:47:21 +0000 |
commit | 7285a491c1ce1e630a0751b1011fd33e6b17234b (patch) | |
tree | b2b2e24e333fa4660325a35f6c0f1d333e50e797 /src/cmd/9660/unix.c | |
parent | e1dddc053287874e82e2b67f95ccee7d7bc63e22 (diff) | |
download | plan9port-7285a491c1ce1e630a0751b1011fd33e6b17234b.tar.gz plan9port-7285a491c1ce1e630a0751b1011fd33e6b17234b.tar.bz2 plan9port-7285a491c1ce1e630a0751b1011fd33e6b17234b.zip |
Dump9660 (and mk9660). Until we either do something
intelligent with symlinks or put in a switch for things
like dump9660, this is of rather limited utility under Unix.
Diffstat (limited to 'src/cmd/9660/unix.c')
-rw-r--r-- | src/cmd/9660/unix.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/cmd/9660/unix.c b/src/cmd/9660/unix.c new file mode 100644 index 00000000..99332af8 --- /dev/null +++ b/src/cmd/9660/unix.c @@ -0,0 +1,84 @@ +#include <u.h> +#include <libc.h> +#include <bio.h> +#include <libsec.h> +#include <disk.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); + xd->symlink = atom("symlink"); // XXX: rsc + } +}; + +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; +} |