141141/*
142142 Handling of multiple SFTP connections
143143 --------------------------------------
144-
144+
145145 An SFTP server is free to return responses to outstanding requests in arbitrary
146146 order. However, execution of requests may only be re-ordered and parallelized as long
147147 as "the results in the responses will be the same as if [the client] had sent the
158158 involved) wait for the other requests to complete. This means that e.g. a readdir
159159 request would have to block on most other activity in the same directory, eliminating a
160160 major advantage of using multiple connections.
161-
161+
162162 In practice, we can luckily take advantage of the knowledge that most FUSE requests are
163163 the result of (synchronous) syscalls from userspace that will block until the
164164 corresponding FUSE response has been sent.
165-
165+
166166 If -o sshfs_sync is used, SSHFS always waits for the SFTP server response before
167167 returning a FUSE response to userspace. If userspace makes concurrent system calls,
168168 there is no ordering guarantee in the first place, so we do not have to worry about
@@ -523,7 +523,7 @@ static struct fuse_opt sshfs_opts[] = {
523523 /* For backwards compatibility */
524524 SSHFS_OPT ("cache=yes" , dir_cache , 1 ),
525525 SSHFS_OPT ("cache=no" , dir_cache , 0 ),
526-
526+
527527 FUSE_OPT_KEY ("writeback_cache=no" , FUSE_OPT_KEY_DISCARD ),
528528 FUSE_OPT_KEY ("unreliable_append" , FUSE_OPT_KEY_DISCARD ),
529529
@@ -1073,7 +1073,7 @@ static struct conn* get_conn(const struct sshfs_file *sf,
10731073
10741074 if (sshfs .max_conns == 1 )
10751075 return & sshfs .conns [0 ];
1076-
1076+
10771077 if (sf != NULL )
10781078 return sf -> conn ;
10791079
@@ -1906,7 +1906,7 @@ static void *sshfs_init(struct fuse_conn_info *conn,
19061906
19071907 // SFTP only supports 1-second time resolution
19081908 conn -> time_gran = 1000000000 ;
1909-
1909+
19101910 return NULL ;
19111911}
19121912
@@ -2371,13 +2371,13 @@ static int sshfs_mkdir(const char *path, mode_t mode)
23712371 // Commutes with pending write(), so we can use any connection
23722372 err = sftp_request (get_conn (NULL , NULL ), SSH_FXP_MKDIR , & buf , SSH_FXP_STATUS , NULL );
23732373 buf_free (& buf );
2374-
2374+
23752375 if (err == - EPERM ) {
23762376 if (sshfs .op -> access (path , R_OK ) == 0 ) {
23772377 return - EEXIST ;
23782378 }
23792379 }
2380-
2380+
23812381 return err ;
23822382}
23832383
@@ -2394,7 +2394,7 @@ static int sshfs_mknod(const char *path, mode_t mode, dev_t rdev)
23942394
23952395 // Commutes with pending write(), so we can use any connection
23962396 conn = get_conn (NULL , NULL );
2397-
2397+
23982398 buf_init (& buf , 0 );
23992399 buf_add_path (& buf , path );
24002400 buf_add_uint32 (& buf , SSH_FXF_WRITE | SSH_FXF_CREAT | SSH_FXF_EXCL );
@@ -2532,7 +2532,7 @@ static int sshfs_rename(const char *from, const char *to, unsigned int flags)
25322532 }
25332533 pthread_mutex_unlock (& sshfs .lock );
25342534 }
2535-
2535+
25362536 return err ;
25372537}
25382538
@@ -2589,12 +2589,12 @@ static int sshfs_chmod(const char *path, mode_t mode,
25892589 buf_init (& buf , 0 );
25902590 if (sf == NULL )
25912591 buf_add_path (& buf , path );
2592- else
2592+ else
25932593 buf_add_buf (& buf , & sf -> handle );
2594-
2594+
25952595 buf_add_uint32 (& buf , SSH_FILEXFER_ATTR_PERMISSIONS );
25962596 buf_add_uint32 (& buf , mode );
2597-
2597+
25982598 /* FIXME: really needs LSETSTAT extension (debian Bug#640038) */
25992599 // Commutes with pending write(), so we can use any connection
26002600 // if the file is not open.
@@ -2618,7 +2618,7 @@ static int sshfs_chown(const char *path, uid_t uid, gid_t gid,
26182618 if (!sshfs_file_is_conn (sf ))
26192619 return - EIO ;
26202620 }
2621-
2621+
26222622 if (sshfs .remote_uid_detected ) {
26232623 if (uid == sshfs .local_uid )
26242624 uid = sshfs .remote_uid ;
@@ -2635,7 +2635,7 @@ static int sshfs_chown(const char *path, uid_t uid, gid_t gid,
26352635 buf_init (& buf , 0 );
26362636 if (sf == NULL )
26372637 buf_add_path (& buf , path );
2638- else
2638+ else
26392639 buf_add_buf (& buf , & sf -> handle );
26402640 buf_add_uint32 (& buf , SSH_FILEXFER_ATTR_UIDGID );
26412641 buf_add_uint32 (& buf , uid );
@@ -2685,7 +2685,7 @@ static int sshfs_utimens(const char *path, const struct timespec tv[2],
26852685 buf_init (& buf , 0 );
26862686 if (sf == NULL )
26872687 buf_add_path (& buf , path );
2688- else
2688+ else
26892689 buf_add_buf (& buf , & sf -> handle );
26902690 buf_add_uint32 (& buf , SSH_FILEXFER_ATTR_ACMODTIME );
26912691 buf_add_uint32 (& buf , asec );
@@ -2740,7 +2740,7 @@ static int sshfs_open_common(const char *path, mode_t mode,
27402740
27412741 if (fi -> flags & O_APPEND )
27422742 pflags |= SSH_FXF_APPEND ;
2743-
2743+
27442744 sf = g_new0 (struct sshfs_file , 1 );
27452745 list_init (& sf -> write_reqs );
27462746 pthread_cond_init (& sf -> write_finished , NULL );
@@ -2750,7 +2750,7 @@ static int sshfs_open_common(const char *path, mode_t mode,
27502750 pthread_mutex_lock (& sshfs .lock );
27512751 sf -> modifver = sshfs .modifver ;
27522752 if (sshfs .max_conns > 1 ) {
2753- ce = g_hash_table_lookup (sshfs .conntab , path );
2753+ ce = g_hash_table_lookup (sshfs .conntab , path );
27542754 if (!ce ) {
27552755 ce = g_malloc (sizeof (struct conntab_entry ));
27562756 ce -> refcount = 0 ;
@@ -3354,7 +3354,7 @@ static int sshfs_truncate(const char *path, off_t size,
33543354 sshfs_inc_modifver ();
33553355 if (sshfs .truncate_workaround )
33563356 return sshfs_truncate_workaround (path , size , fi );
3357-
3357+
33583358 buf_init (& buf , 0 );
33593359
33603360 if (sf != NULL )
@@ -3397,7 +3397,7 @@ static int sshfs_getattr(const char *path, struct stat *stbuf,
33973397 buf_add_buf (& buf , & sf -> handle );
33983398 err = sftp_request (sf -> conn , SSH_FXP_FSTAT , & buf ,
33993399 SSH_FXP_ATTRS , & outbuf );
3400- }
3400+ }
34013401 if (!err ) {
34023402 err = buf_get_attrs (& outbuf , stbuf , NULL );
34033403#ifdef __APPLE__
0 commit comments