Fri Oct 29 16:13:51 2010 UTC ()
Make error message more userfriendly in cases where server does
not support sftp.


(pooka)
diff -r1.22 -r1.23 src/usr.sbin/puffs/mount_psshfs/fs.c
diff -r1.61 -r1.62 src/usr.sbin/puffs/mount_psshfs/node.c
diff -r1.61 -r1.62 src/usr.sbin/puffs/mount_psshfs/psshfs.c

cvs diff -r1.22 -r1.23 src/usr.sbin/puffs/mount_psshfs/fs.c (expand / switch to unified diff)

--- src/usr.sbin/puffs/mount_psshfs/fs.c 2010/04/01 02:34:09 1.22
+++ src/usr.sbin/puffs/mount_psshfs/fs.c 2010/10/29 16:13:51 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fs.c,v 1.22 2010/04/01 02:34:09 pooka Exp $ */ 1/* $NetBSD: fs.c,v 1.23 2010/10/29 16:13:51 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006-2009 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2006-2009 Antti Kantee. 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 *
@@ -17,48 +17,46 @@ @@ -17,48 +17,46 @@
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29#ifndef lint 29#ifndef lint
30__RCSID("$NetBSD: fs.c,v 1.22 2010/04/01 02:34:09 pooka Exp $"); 30__RCSID("$NetBSD: fs.c,v 1.23 2010/10/29 16:13:51 pooka Exp $");
31#endif /* !lint */ 31#endif /* !lint */
32 32
33#include <err.h> 33#include <err.h>
34#include <errno.h> 34#include <errno.h>
35#include <puffs.h> 35#include <puffs.h>
36#include <signal.h> 36#include <signal.h>
37#include <stdio.h> 37#include <stdio.h>
38#include <stdlib.h> 38#include <stdlib.h>
39#include <unistd.h> 39#include <unistd.h>
40 40
41#include "psshfs.h" 41#include "psshfs.h"
42#include "sftp_proto.h" 42#include "sftp_proto.h"
43 43
44#define DO_IO(fname, a1, a2, a3, a4, rv) \ 44#define DO_IO(fname, a1, a2, a3, a4, rv) \
45do { \ 45do { \
46 puffs_framebuf_seekset(a2, 0); \ 46 puffs_framebuf_seekset(a2, 0); \
47 *(a4) = 0; \ 47 *(a4) = 0; \
48 rv = fname(a1, a2, a3, a4); \ 48 rv = fname(a1, a2, a3, a4); \
49 if (rv || a4 == 0) { \ 49 if (rv || a4 == 0) { \
50 fprintf(stderr, "psshfs_handshake failed %d (%s) %d\n", \ 
51 rv, strerror(rv), *a4); \ 
52 return rv ? rv : EPROTO; \ 50 return rv ? rv : EPROTO; \
53 } \ 51 } \
54} while (/*CONSTCOND*/0) 52} while (/*CONSTCOND*/0)
55 53
56#define reterr(str, rv) \ 54#define reterr(str, rv) \
57do { \ 55do { \
58 fprintf str; \ 56 fprintf str; \
59 return rv; \ 57 return rv; \
60} while (/*CONSTCOND*/0) 58} while (/*CONSTCOND*/0)
61 59
62/* openssh extensions */ 60/* openssh extensions */
63static const struct extunit { 61static const struct extunit {
64 const char *ext; 62 const char *ext;
@@ -72,27 +70,27 @@ static const struct extunit { @@ -72,27 +70,27 @@ static const struct extunit {
72},{ 70},{
73 "statvfs@openssh.com", 71 "statvfs@openssh.com",
74 "2", 72 "2",
75 SFTP_EXT_STATVFS, 73 SFTP_EXT_STATVFS,
76},{ 74},{
77 "fstatvfs@openssh.com", 75 "fstatvfs@openssh.com",
78 "2", 76 "2",
79 SFTP_EXT_FSTATVFS, 77 SFTP_EXT_FSTATVFS,
80},{ 78},{
81 NULL, 79 NULL,
82 NULL, 80 NULL,
83 0 81 0
84}}; 82}};
85  83
86int 84int
87psshfs_handshake(struct puffs_usermount *pu, int fd) 85psshfs_handshake(struct puffs_usermount *pu, int fd)
88{ 86{
89 struct psshfs_ctx *pctx = puffs_getspecific(pu); 87 struct psshfs_ctx *pctx = puffs_getspecific(pu);
90 struct puffs_framebuf *pb; 88 struct puffs_framebuf *pb;
91 struct puffs_pathobj *po_root; 89 struct puffs_pathobj *po_root;
92 struct puffs_node *pn_root; 90 struct puffs_node *pn_root;
93 struct vattr va, *rva; 91 struct vattr va, *rva;
94 const struct extunit *extu; 92 const struct extunit *extu;
95 char *rootpath; 93 char *rootpath;
96 char *ext, *val; 94 char *ext, *val;
97 uint32_t count; 95 uint32_t count;
98 int rv, done; 96 int rv, done;

cvs diff -r1.61 -r1.62 src/usr.sbin/puffs/mount_psshfs/node.c (expand / switch to unified diff)

--- src/usr.sbin/puffs/mount_psshfs/node.c 2010/04/01 02:34:09 1.61
+++ src/usr.sbin/puffs/mount_psshfs/node.c 2010/10/29 16:13:51 1.62
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: node.c,v 1.61 2010/04/01 02:34:09 pooka Exp $ */ 1/* $NetBSD: node.c,v 1.62 2010/10/29 16:13:51 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006-2009 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2006-2009 Antti Kantee. 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 *
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29#ifndef lint 29#ifndef lint
30__RCSID("$NetBSD: node.c,v 1.61 2010/04/01 02:34:09 pooka Exp $"); 30__RCSID("$NetBSD: node.c,v 1.62 2010/10/29 16:13:51 pooka Exp $");
31#endif /* !lint */ 31#endif /* !lint */
32 32
33#include <assert.h> 33#include <assert.h>
34#include <errno.h> 34#include <errno.h>
35#include <stdio.h> 35#include <stdio.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include "psshfs.h" 38#include "psshfs.h"
39#include "sftp_proto.h" 39#include "sftp_proto.h"
40 40
41int 41int
42psshfs_node_lookup(struct puffs_usermount *pu, puffs_cookie_t opc, 42psshfs_node_lookup(struct puffs_usermount *pu, puffs_cookie_t opc,
43 struct puffs_newinfo *pni, const struct puffs_cn *pcn) 43 struct puffs_newinfo *pni, const struct puffs_cn *pcn)
@@ -352,28 +352,29 @@ psshfs_node_readdir(struct puffs_usermou @@ -352,28 +352,29 @@ psshfs_node_readdir(struct puffs_usermou
352 set_readdir = 0; 352 set_readdir = 0;
353 pw.pw_cc = pcc; 353 pw.pw_cc = pcc;
354 pw.pw_type = PWTYPE_READDIR; 354 pw.pw_type = PWTYPE_READDIR;
355 TAILQ_INSERT_TAIL(&psn->pw, &pw, pw_entries); 355 TAILQ_INSERT_TAIL(&psn->pw, &pw, pw_entries);
356 puffs_cc_yield(pcc); 356 puffs_cc_yield(pcc);
357 goto restart; 357 goto restart;
358 } else { 358 } else {
359 psn->stat |= PSN_READDIR; 359 psn->stat |= PSN_READDIR;
360 set_readdir = 1; 360 set_readdir = 1;
361 } 361 }
362 362
363 *ncookies = 0; 363 *ncookies = 0;
364 rv = sftp_readdir(pu, pctx, pn); 364 rv = sftp_readdir(pu, pctx, pn);
365 if (rv) 365 if (rv) {
366 goto out; 366 goto out;
 367 }
367 368
368 /* find next dirent */ 369 /* find next dirent */
369 for (i = *readoff;;i++) { 370 for (i = *readoff;;i++) {
370 if (i >= psn->dentnext) 371 if (i >= psn->dentnext)
371 goto out; 372 goto out;
372 pd = &psn->dir[i]; 373 pd = &psn->dir[i];
373 if (pd->valid) 374 if (pd->valid)
374 break; 375 break;
375 } 376 }
376 377
377 for (;;) { 378 for (;;) {
378 *readoff = i; 379 *readoff = i;
379 if (!puffs_nextdent(&dent, pd->entryname, 380 if (!puffs_nextdent(&dent, pd->entryname,

cvs diff -r1.61 -r1.62 src/usr.sbin/puffs/mount_psshfs/psshfs.c (expand / switch to unified diff)

--- src/usr.sbin/puffs/mount_psshfs/psshfs.c 2010/02/17 15:54:10 1.61
+++ src/usr.sbin/puffs/mount_psshfs/psshfs.c 2010/10/29 16:13:51 1.62
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: psshfs.c,v 1.61 2010/02/17 15:54:10 pooka Exp $ */ 1/* $NetBSD: psshfs.c,v 1.62 2010/10/29 16:13:51 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2006-2009 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2006-2009 Antti Kantee. 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 *
@@ -31,27 +31,27 @@ @@ -31,27 +31,27 @@
31 * psshfs implements sshfs functionality on top of puffs making it 31 * psshfs implements sshfs functionality on top of puffs making it
32 * possible to mount a filesystme through the sftp service. 32 * possible to mount a filesystme through the sftp service.
33 * 33 *
34 * psshfs can execute multiple operations in "parallel" by using the 34 * psshfs can execute multiple operations in "parallel" by using the
35 * puffs_cc framework for continuations. 35 * puffs_cc framework for continuations.
36 * 36 *
37 * Concurrency control is handled currently by vnode locking (this 37 * Concurrency control is handled currently by vnode locking (this
38 * will change in the future). Context switch locations are easy to 38 * will change in the future). Context switch locations are easy to
39 * find by grepping for puffs_framebuf_enqueue_cc(). 39 * find by grepping for puffs_framebuf_enqueue_cc().
40 */ 40 */
41 41
42#include <sys/cdefs.h> 42#include <sys/cdefs.h>
43#ifndef lint 43#ifndef lint
44__RCSID("$NetBSD: psshfs.c,v 1.61 2010/02/17 15:54:10 pooka Exp $"); 44__RCSID("$NetBSD: psshfs.c,v 1.62 2010/10/29 16:13:51 pooka Exp $");
45#endif /* !lint */ 45#endif /* !lint */
46 46
47#include <sys/types.h> 47#include <sys/types.h>
48#include <sys/wait.h> 48#include <sys/wait.h>
49 49
50#include <assert.h> 50#include <assert.h>
51#include <err.h> 51#include <err.h>
52#include <errno.h> 52#include <errno.h>
53#include <mntopts.h> 53#include <mntopts.h>
54#include <paths.h> 54#include <paths.h>
55#include <poll.h> 55#include <poll.h>
56#include <puffs.h> 56#include <puffs.h>
57#include <signal.h> 57#include <signal.h>
@@ -405,27 +405,27 @@ pssh_connect(struct puffs_usermount *pu, @@ -405,27 +405,27 @@ pssh_connect(struct puffs_usermount *pu,
405 dup2(dnfd, STDERR_FILENO); 405 dup2(dnfd, STDERR_FILENO);
406 406
407 execvp(sshargs[0], sshargs); 407 execvp(sshargs[0], sshargs);
408 /*NOTREACHED*/ 408 /*NOTREACHED*/
409 break; 409 break;
410 default: 410 default:
411 *sshpid = pid; 411 *sshpid = pid;
412 *sshfd = fds[1]; 412 *sshfd = fds[1];
413 close(fds[0]); 413 close(fds[0]);
414 break; 414 break;
415 } 415 }
416 416
417 if (psshfs_handshake(pu, *sshfd) != 0) 417 if (psshfs_handshake(pu, *sshfd) != 0)
418 errx(1, "psshfs_handshake %d", which); 418 errx(1, "handshake failed, server does not support sftp?");
419 x = 1; 419 x = 1;
420 if (ioctl(*sshfd, FIONBIO, &x) == -1) 420 if (ioctl(*sshfd, FIONBIO, &x) == -1)
421 err(1, "nonblocking descriptor %d", which); 421 err(1, "nonblocking descriptor %d", which);
422 422
423 return *sshfd; 423 return *sshfd;
424} 424}
425 425
426static void * 426static void *
427invalone(struct puffs_usermount *pu, struct puffs_node *pn, void *arg) 427invalone(struct puffs_usermount *pu, struct puffs_node *pn, void *arg)
428{ 428{
429 struct psshfs_node *psn = pn->pn_data; 429 struct psshfs_node *psn = pn->pn_data;
430 430
431 psn->attrread = 0; 431 psn->attrread = 0;