Add mknod(2) support.
Submitted by: Jan Senolt <senoltj@centrum.cz> Submitted by: Milan Cermak <Milan.Cermak@Sun.COM>
This commit is contained in:
parent
9fed776db8
commit
3898aedc01
@ -27,9 +27,13 @@
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#ifndef makedev
|
||||
#include <sys/mkdev.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
@ -66,6 +70,7 @@ enum action {
|
||||
ACTION_SYMLINK,
|
||||
ACTION_RENAME,
|
||||
ACTION_MKFIFO,
|
||||
ACTION_MKNOD,
|
||||
ACTION_BIND,
|
||||
ACTION_CONNECT,
|
||||
ACTION_CHMOD,
|
||||
@ -115,6 +120,7 @@ static struct syscall_desc syscalls[] = {
|
||||
{ "symlink", ACTION_SYMLINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
|
||||
{ "rename", ACTION_RENAME, { TYPE_STRING, TYPE_STRING, TYPE_NONE } },
|
||||
{ "mkfifo", ACTION_MKFIFO, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
|
||||
{ "mknod", ACTION_MKNOD, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} },
|
||||
{ "bind", ACTION_BIND, { TYPE_STRING, TYPE_NONE } },
|
||||
{ "connect", ACTION_CONNECT, { TYPE_STRING, TYPE_NONE } },
|
||||
{ "chmod", ACTION_CHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
|
||||
@ -359,6 +365,10 @@ show_stat(struct stat64 *sp, const char *what)
|
||||
else if (strcmp(what, "flags") == 0)
|
||||
printf("%s", flags2str(chflags_flags, (long long)sp->st_flags));
|
||||
#endif
|
||||
else if (strcmp(what, "major") == 0)
|
||||
printf("%u", (unsigned int)major(sp->st_rdev));
|
||||
else if (strcmp(what, "minor") == 0)
|
||||
printf("%u", (unsigned int)minor(sp->st_rdev));
|
||||
else if (strcmp(what, "type") == 0) {
|
||||
switch (sp->st_mode & S_IFMT) {
|
||||
case S_IFIFO:
|
||||
@ -503,6 +513,29 @@ call_syscall(struct syscall_desc *scall, char *argv[])
|
||||
case ACTION_MKFIFO:
|
||||
rval = mkfifo(STR(0), (mode_t)NUM(1));
|
||||
break;
|
||||
case ACTION_MKNOD:
|
||||
{
|
||||
mode_t ntype;
|
||||
dev_t dev;
|
||||
|
||||
dev = makedev(NUM(3), NUM(4));
|
||||
if (strcmp(STR(1), "c") == 0) /* character device */
|
||||
ntype = S_IFCHR;
|
||||
else if (strcmp(STR(1), "b") == 0) /* block device */
|
||||
ntype = S_IFBLK;
|
||||
else if (strcmp(STR(1), "f") == 0) /* fifo special */
|
||||
ntype = S_IFIFO;
|
||||
else if (strcmp(STR(1), "d") == 0) /* directory */
|
||||
ntype = S_IFDIR;
|
||||
else if (strcmp(STR(1), "o") == 0) /* regular file */
|
||||
ntype = S_IFREG;
|
||||
else {
|
||||
fprintf(stderr, "wrong argument 1\n");
|
||||
exit(1);
|
||||
}
|
||||
rval = mknod(STR(0), ntype | NUM(2), dev);
|
||||
break;
|
||||
}
|
||||
case ACTION_BIND:
|
||||
{
|
||||
struct sockaddr_un sun;
|
||||
|
Loading…
x
Reference in New Issue
Block a user