@@ -83,6 +83,8 @@ static struct fuse_opt fs_opts[] = {
8383 CRYPT4GH_SQLITE_OPT ("seckey=%s" , seckeypath , 0 ),
8484 CRYPT4GH_SQLITE_OPT ("passphrase_from_env=%s" , passphrase_from_env , 0 ),
8585
86+ CRYPT4GH_SQLITE_OPT ("parent_fd=%u" , parent_fd , -1 ),
87+
8688 /* if multithreaded */
8789 CRYPT4GH_SQLITE_OPT ("-s" , singlethread , 1 ),
8890 CRYPT4GH_SQLITE_OPT ("clone_fd" , clone_fd , 1 ),
@@ -205,10 +207,16 @@ c4gh_init(void)
205207{
206208 int res = 0 ;
207209
208- D1 ("Initializing the file system" );
210+ if (config .seckeypath == NULL ){
211+ D1 ("Crypt4GH decryption disabled" );
212+ return 0 ; // it's allowed
213+ }
214+
215+ D1 ("Initializing Crypt4GH" );
216+ D1 ("Secret key path: %s" , config .seckeypath );
209217
210- if (! config . seckeypath || * config .seckeypath != '/' ){
211- E ("Missing secret key path, or non- absolute path" );
218+ if (* config .seckeypath != '/' ){
219+ E ("Secret key must be an absolute path" );
212220 res ++ ;
213221 goto bailout ;
214222 }
@@ -288,6 +296,7 @@ int main(int argc, char *argv[])
288296 config .singlethread = 0 ;
289297 config .foreground = 0 ;
290298 config .mounted_at = time (NULL );
299+ config .parent_fd = -1 ;
291300
292301 config .entry_timeout = DEFAULT_ENTRY_TIMEOUT ;
293302 config .attr_timeout = DEFAULT_ATTR_TIMEOUT ;
@@ -436,6 +445,19 @@ int main(int argc, char *argv[])
436445 config .fperm ,
437446 config .dperm );
438447
448+ /* Notify the parent */
449+ if (config .parent_fd > 0 ){
450+ char data = '1' ;
451+ if (write (config .parent_fd , & data , 1 ) != 1 ){
452+ E ("Error writing back to the parent: %s" , strerror (errno ));
453+ res = 7 ;
454+ /* should we close the parent_fd on error ? */
455+ goto bailout_unmount ;
456+ }
457+ close (config .parent_fd );
458+ config .parent_fd = -1 ;
459+ }
460+
439461 if (config .singlethread ){
440462 D2 ("Mode: single-threaded" );
441463 res = fuse_session_loop (se );
0 commit comments