| @@ -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); |
2419 | out: | | 2425 | out: |
2420 | ps->ps_destroy_msg(pm); | | 2426 | ps->ps_destroy_msg(pm); |
2421 | | | 2427 | |
2422 | return error; | | 2428 | return error; |
2423 | } | | 2429 | } |
2424 | | | 2430 | |
2425 | int | | 2431 | int |
2426 | perfuse_node_reclaim(pu, opc) | | 2432 | perfuse_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; |