summaryrefslogtreecommitdiff
path: root/tmpfs
diff options
context:
space:
mode:
authorBen Asselstine <benasselstine@gmail.com>2011-11-20 11:00:26 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-11-20 11:00:26 +0100
commit078937c89aa2c93796ba7b64c474c30ddbdad38a (patch)
treefa06d19414efcbb7c0d9fee84c05d1ea55338b24 /tmpfs
parentb30813c7b942f1146def88ac52f8179947294e49 (diff)
Fix symlink support in tmpfs
* node.c (create_symlink_hook): Set NP->dn_stat.st_size to the length of TARGET. (create_symlink_hook): Set NP->dn->type to DT_LNK. (diskfs_truncate): Do NP->allocsize check after symlink check.
Diffstat (limited to 'tmpfs')
-rw-r--r--tmpfs/node.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/tmpfs/node.c b/tmpfs/node.c
index b2503a05..ccc077ca 100644
--- a/tmpfs/node.c
+++ b/tmpfs/node.c
@@ -332,6 +332,7 @@ static error_t
create_symlink_hook (struct node *np, const char *target)
{
assert (np->dn->u.lnk == 0);
+ np->dn_stat.st_size = strlen (target);
if (np->dn_stat.st_size > 0)
{
const size_t size = np->dn_stat.st_size + 1;
@@ -339,6 +340,7 @@ create_symlink_hook (struct node *np, const char *target)
if (np->dn->u.lnk == 0)
return ENOSPC;
memcpy (np->dn->u.lnk, target, size);
+ np->dn->type = DT_LNK;
adjust_used (size);
recompute_blocks (np);
}
@@ -382,9 +384,6 @@ diskfs_node_reload (struct node *node)
error_t
diskfs_truncate (struct node *np, off_t size)
{
- if (np->allocsize <= size)
- return 0;
-
if (np->dn->type == DT_LNK)
{
free (np->dn->u.lnk);
@@ -394,6 +393,9 @@ diskfs_truncate (struct node *np, off_t size)
return 0;
}
+ if (np->allocsize <= size)
+ return 0;
+
assert (np->dn->type == DT_REG);
if (default_pager == MACH_PORT_NULL)