Mon Oct 11 01:52:05 2010 UTC ()
FUSE filesystems' readlink returns a resolved link with a NUL trailing
character, and PUFFS do not want it. This fixes this bug, that returned
stat the informations for x instead of reporting ENOENT:
mkdir x && ln x z && stat -x z/whatever/you/want


(manu)
diff -r1.21 -r1.22 src/lib/libperfuse/ops.c

cvs diff -r1.21 -r1.22 src/lib/libperfuse/ops.c (expand / switch to unified diff)

--- src/lib/libperfuse/ops.c 2010/10/11 01:08:26 1.21
+++ src/lib/libperfuse/ops.c 2010/10/11 01:52:05 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ops.c,v 1.21 2010/10/11 01:08:26 manu Exp $ */ 1/* $NetBSD: ops.c,v 1.22 2010/10/11 01:52:05 manu Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved. 4 * Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
5 *  5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 *  14 *
@@ -2400,32 +2400,38 @@ perfuse_node_readlink(pu, opc, pcr, link @@ -2400,32 +2400,38 @@ perfuse_node_readlink(pu, opc, pcr, link
2400 if (no_access((puffs_cookie_t)PERFUSE_NODE_DATA(opc)->pnd_parent, 2400 if (no_access((puffs_cookie_t)PERFUSE_NODE_DATA(opc)->pnd_parent,
2401 pcr, PUFFS_VREAD) || 2401 pcr, PUFFS_VREAD) ||
2402 no_access(opc, pcr, PUFFS_VREAD)) 2402 no_access(opc, pcr, PUFFS_VREAD))
2403 return EACCES; 2403 return EACCES;
2404 2404
2405 ps = puffs_getspecific(pu); 2405 ps = puffs_getspecific(pu);
2406 2406
2407 pm = ps->ps_new_msg(pu, opc, FUSE_READLINK, 0, pcr); 2407 pm = ps->ps_new_msg(pu, opc, FUSE_READLINK, 0, pcr);
2408 2408
2409 if ((error = xchg_msg(pu, opc, pm, UNSPEC_REPLY_LEN, wait_reply)) != 0) 2409 if ((error = xchg_msg(pu, opc, pm, UNSPEC_REPLY_LEN, wait_reply)) != 0)
2410 goto out; 2410 goto out;
2411 2411
2412 foh = GET_OUTHDR(ps, pm); 2412 foh = GET_OUTHDR(ps, pm);
2413 len = foh->len - sizeof(*foh) + 1; 2413 len = foh->len - sizeof(*foh);
2414 if (len > *linklen) 2414 if (len > *linklen)
2415 DERRX(EX_PROTOCOL, "path len = %zd too long", len); 2415 DERRX(EX_PROTOCOL, "path len = %zd too long", len);
 2416 if (len == 0)
 2417 DERRX(EX_PROTOCOL, "path len = %zd too short", len);
2416  2418
2417 *linklen = len; 2419 /*
2418 (void)strlcpy(linkname, _GET_OUTPAYLOAD(ps, pm, char *), len); 2420 * FUSE filesystems return a NUL terminated string, we
 2421 * do not want to trailing \0
 2422 */
 2423 *linklen = len - 1;
 2424 (void)memcpy(linkname, _GET_OUTPAYLOAD(ps, pm, char *), len);
2419out: 2425out:
2420 ps->ps_destroy_msg(pm); 2426 ps->ps_destroy_msg(pm);
2421 2427
2422 return error; 2428 return error;
2423} 2429}
2424 2430
2425int  2431int
2426perfuse_node_reclaim(pu, opc) 2432perfuse_node_reclaim(pu, opc)
2427 struct puffs_usermount *pu; 2433 struct puffs_usermount *pu;
2428 puffs_cookie_t opc; 2434 puffs_cookie_t opc;
2429{ 2435{
2430 struct perfuse_state *ps; 2436 struct perfuse_state *ps;
2431 perfuse_msg_t *pm; 2437 perfuse_msg_t *pm;