diff options
author | Roland McGrath <roland@gnu.org> | 1996-03-12 13:36:06 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1996-03-12 13:36:06 +0000 |
commit | 9a47313945e7f1bdbd389f6cc2a456044c5765be (patch) | |
tree | 10074dca81e9fffe5ddede7718df4e3be9948aa7 | |
parent | a542755511b4d002eca5bbc409270ccabe62aeb4 (diff) |
entered into RCS
-rw-r--r-- | libnetfs/file-get-translator.c | 23 |
1 files changed, 12 insertions, 11 deletions
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; |