From 9a47313945e7f1bdbd389f6cc2a456044c5765be Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 12 Mar 1996 13:36:06 +0000 Subject: entered into RCS --- libnetfs/file-get-translator.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'libnetfs') diff --git a/libnetfs/file-get-translator.c b/libnetfs/file-get-translator.c index 703eed6f..ebad95ac 100644 --- a/libnetfs/file-get-translator.c +++ b/libnetfs/file-get-translator.c @@ -1,4 +1,4 @@ -/* +/* Copyright (C) 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. @@ -30,20 +30,20 @@ netfs_S_file_get_translator (struct protid *user, { struct node *np; error_t err; - + if (!user) return EOPNOTSUPP; np = user->po->np; mutex_lock (&np->lock); err = netfs_validate_stat (np, user->credential); - + if (err) { mutex_unlock (&np->lock); return err; } - + if (S_ISLNK (np->nn_stat.st_mode)) { unsigned int len = sizeof _HURD_SYMLINK + np->nn_stat.st_size + 1; @@ -52,7 +52,7 @@ netfs_S_file_get_translator (struct protid *user, vm_allocate (mach_task_self (), (vm_address_t *)trans, len, 1); bcopy (_HURD_SYMLINK, *trans, sizeof _HURD_SYMLINK); - err = netfs_attempt_readlink (user->credential, np, + err = netfs_attempt_readlink (user->credential, np, *trans + sizeof _HURD_SYMLINK); if (!err) { @@ -65,24 +65,25 @@ netfs_S_file_get_translator (struct protid *user, char *buf; unsigned int buflen; - buflen = asprintf (&buf, "%s%c%d%c%d", - (S_ISCHR (np->nn_stat.st_mode) + buflen = asprintf (&buf, "%s%c%d%c%d", + (S_ISCHR (np->nn_stat.st_mode) ? _HURD_CHRDEV : _HURD_BLKDEV), '\0', (np->nn_stat.st_rdev >> 8) & 0377, '\0', (np->nn_stat.st_rdev) & 0377); buflen++; /* terminating nul */ - + if (buflen > *translen) vm_allocate (mach_task_self (), (vm_address_t *) trans, buflen, 1); bcopy (buf, *trans, buflen); + free (buf); *translen = buflen; err = 0; } else if (S_ISFIFO (np->nn_stat.st_mode)) { unsigned int len; - + len = sizeof _HURD_FIFO; if (len > *translen) vm_allocate (mach_task_self (), (vm_address_t *) trans, len, 1); @@ -93,7 +94,7 @@ netfs_S_file_get_translator (struct protid *user, else if (S_ISSOCK (np->nn_stat.st_mode)) { unsigned int len; - + len = sizeof _HURD_IFSOCK; if (len > *translen) vm_allocate (mach_task_self (), (vm_address_t *) trans, len, 1); @@ -103,7 +104,7 @@ netfs_S_file_get_translator (struct protid *user, } else err = EINVAL; - + mutex_unlock (&np->lock); return err; -- cgit v1.2.3