From 078937c89aa2c93796ba7b64c474c30ddbdad38a Mon Sep 17 00:00:00 2001 From: Ben Asselstine Date: Sun, 20 Nov 2011 11:00:26 +0100 Subject: 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. --- tmpfs/node.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tmpfs/node.c') 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) -- cgit v1.2.3