From adc48b9a8151337de1210a52d07f69d2bc265054 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 13 Jul 1994 18:46:48 +0000 Subject: Formerly file-get-trans.c.~9~ --- libdiskfs/file-get-trans.c | 47 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'libdiskfs') diff --git a/libdiskfs/file-get-trans.c b/libdiskfs/file-get-trans.c index 1c44b332..617be529 100644 --- a/libdiskfs/file-get-trans.c +++ b/libdiskfs/file-get-trans.c @@ -54,7 +54,52 @@ diskfs_S_file_get_translator (struct protid *cred, *translen = len; } } - /* XXX should also do IFCHR, IFBLK, IFIFO, and IFSOCK here. */ + else if (S_ISCHR (np->dn_stat.st_mode) || S_ISBLK (np->dn_stat.st_mode)) + { + char *buf; + int buflen; + + if (S_ISCHR (np->dn_stat.st_mode)) + assert (diskfs_shortcut_chrdev); + else + assert (diskfs_shortcut_blkdev); + + buflen = asprintf (&buf, "%s%c%d%c%d", + (S_ISCHR (np->dn_stat.st_mode) + ? _HURD_CHRDEV + : _HURD_BLKDEV), + '\0', (np->dn_stat.st_rdev >> 8) & 0377, + '\0', (np->dn_stat.st_rdev) & 0377); + buflen++; /* terminating nul */ + + if (buflen > *translen) + vm_allocate (mach_task_self (), (vm_address_t) trans, len, 1); + bcopy (buf, *trans, buflen); + *translen = buflen; + error = 0; + } + else if (S_ISFIFO (np->dn_stat.st_mode)) + { + int len; + + len = sizeof _HURD_FIFO; + if (len > *translen) + vm_allocate (mach_task_self (), (vm_address_t) trans, len, 1); + bcopy (_HURD_FIFO, *trans, sizeof _HURD_FIFO); + *translen = len; + error = 0; + } + else if (S_ISSOCK (np->dn_stat.st_mode)) + { + int len; + + len = sizeof _HURD_IFSOCK; + if (len > *translen) + vm_allocate (mach_task_self (), (vm_address_t) trans, len, 1); + bcopy (_HURD_IFSOCK, *trans, sizeof _HURD_IFSOCK); + *translen = len; + error = 0; + } else { if (!diskfs_node_translated (np)) -- cgit v1.2.3