You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "diqiu50 (via GitHub)" <gi...@apache.org> on 2025/01/17 10:33:35 UTC

[PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse [gravitino]

diqiu50 opened a new pull request, #6321:
URL: https://github.com/apache/gravitino/pull/6321

   ### What changes were proposed in this pull request?
   
   1. Support mount and umount command
   2. Make mount create a daemon process to run background
   
   
   ### Why are the changes needed?
   
   Fix: #6320 
   
   ### Does this PR introduce _any_ user-facing change?
   
   No
   
   ### How was this patch tested?
   
   IT
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1942487574


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        location: String,

Review Comment:
   Change `location` to `fileset_location`
   The parameter of `config` is very common. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1945892421


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        location: String,

Review Comment:
   fix, add an example



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1942487574


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        location: String,

Review Comment:
   Change `location` to `fileset_location`
   Using "config" as a configuration name is very common.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao merged PR #6321:
URL: https://github.com/apache/gravitino/pull/6321


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "tengqm (via GitHub)" <gi...@apache.org>.
tengqm commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1921897892


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "Location of GVFS fileset URI")]

Review Comment:
   A URI is almost a location, how about
   
   ```suggestion
           #[arg(help = "The URI of the GVFS fileset")]
   ```



##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "Location of GVFS fileset URI")]
+        location: String,
+
+        #[arg(short, long)]
+        config: Option<String>,
+
+        #[arg(short, long, help = "Debug level", default_value_t = 0)]
+        debug: u8,

Review Comment:
   Looks like this is an overdesign?
   Are we really using this argument?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1942412103


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        location: String,

Review Comment:
   The meaning of `location` and `config` seems not clear



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1945887279


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "0.1",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        fileset_location: String,
+
+        #[arg(short, long)]
+        config: Option<String>,

Review Comment:
   For most software, `--config` and `-c` are used to refer to the configuration file path, right? Won't using this affect user habits?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1945882932


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "0.1",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        fileset_location: String,
+
+        #[arg(short, long)]
+        config: Option<String>,

Review Comment:
   config -> config_file_path?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1945884458


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        location: String,

Review Comment:
   could you provide an example of `fileset_location` and add the example to the help message? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1942405075


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",

Review Comment:
   is this version correct?  `1.0` seems a stable version.



##########
clients/filesystem-fuse/src/main.rs:
##########
@@ -16,49 +16,214 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-use fuse3::Errno;
+mod command_args;
+
+use crate::command_args::Commands;
+use clap::Parser;
+use daemonize::Daemonize;
 use gvfs_fuse::config::AppConfig;
-use gvfs_fuse::{gvfs_mount, gvfs_unmount};
+use gvfs_fuse::{gvfs_mount, gvfs_unmount, LOG_FILE_NAME, PID_FILE_NAME};
 use log::{error, info};
+use std::fs::{create_dir, OpenOptions};
+use std::io;
+use std::path::Path;
+use std::process::Command;
+use tokio::runtime::Runtime;
 use tokio::signal;
+use tokio::signal::unix::{signal, SignalKind};
 
-#[tokio::main]
-async fn main() -> fuse3::Result<()> {
-    tracing_subscriber::fmt().init();
+fn init_work_dirs(config: &AppConfig, mount_point: &str) -> io::Result<()> {
+    let data_dir_name = Path::new(&config.fuse.data_dir).to_path_buf();
+    let data_dir_name = data_dir_name.canonicalize()?;
+    if !data_dir_name.exists() {
+        Err(io::Error::new(
+            io::ErrorKind::NotFound,
+            format!("Data directory {} not found", &config.fuse.data_dir),
+        ))?
+    };
 
-    // todo need inmprove the args parsing
-    let args: Vec<String> = std::env::args().collect();
-    let (mount_point, mount_from, config_path) = match args.len() {
-        4 => (args[1].clone(), args[2].clone(), args[3].clone()),
-        _ => {
-            error!("Usage: {} <mount_point> <mount_from> <config>", args[0]);
-            return Err(Errno::from(libc::EINVAL));
-        }
+    let mount_point_name = data_dir_name.join(mount_point);
+    if !mount_point_name.exists() {
+        create_dir(&mount_point_name)?
+    };
+
+    let log_dir_name = data_dir_name.join(&config.fuse.log_dir);
+    if !log_dir_name.exists() {
+        create_dir(&log_dir_name)?
     };
 
-    //todo(read config file from args)
-    let config = AppConfig::from_file(Some(&config_path));
-    if let Err(e) = &config {
-        error!("Failed to load config: {:?}", e);
-        return Err(Errno::from(libc::EINVAL));
+    Ok(())
+}
+
+fn make_daemon(config: &AppConfig) -> io::Result<()> {
+    let data_dir_name = Path::new(&config.fuse.data_dir);
+    let log_dir_name = data_dir_name.join(&config.fuse.log_dir);
+    let log_file_name = log_dir_name.join(LOG_FILE_NAME);
+    let log_file = OpenOptions::new()
+        .create(true)
+        .append(true)
+        .open(&log_file_name)
+        .unwrap();
+    let log_err_file = OpenOptions::new().append(true).open(log_file_name).unwrap();
+
+    let pid_file_name = data_dir_name.join(PID_FILE_NAME);
+
+    let daemonize = Daemonize::new()
+        .pid_file(pid_file_name)
+        .chown_pid_file(true)
+        .working_directory(data_dir_name)
+        .stdout(log_file)
+        .stderr(log_err_file);
+
+    match daemonize.start() {
+        Ok(_) => info!("Gvfs-fuse Daemon started successfully"),
+        Err(e) => {
+            return Err(io::Error::new(
+                io::ErrorKind::Other,
+                format!("Gvfs-fuse Daemon failed to start: {:?}", e),
+            ))
+        }
     }
-    let config = config.unwrap();
-    let handle = tokio::spawn(async move {
-        let result = gvfs_mount(&mount_point, &mount_from, &config).await;
-        if let Err(e) = result {
-            error!("Failed to mount gvfs: {:?}", e);
-            return Err(Errno::from(libc::EINVAL));
+    Ok(())
+}
+
+fn mount_fuse(config: AppConfig, mount_point: String, target: String) -> io::Result<()> {
+    let rt = Runtime::new()?;
+    rt.block_on(async {
+        let handle = tokio::spawn(async move {
+            let result = gvfs_mount(&mount_point, &target, &config).await;
+            if let Err(e) = result {
+                error!("Failed to mount gvfs: {:?}", e);
+                return Err(io::Error::from(io::ErrorKind::InvalidInput));
+            }
+            Ok(())
+        });
+
+        let mut term_signal = signal(SignalKind::terminate())?;
+        tokio::select! {
+            _ = handle => {}
+            _ = signal::ctrl_c() => {
+                    info!("Received Ctrl+C, unmounting gvfs...")
+                }
+            _ = term_signal.recv()=> {
+                    info!("Received SIGTERM, unmounting gvfs...")
+                }
         }
+
+        let _ = gvfs_unmount().await;
         Ok(())
-    });
+    })
+}
 
-    tokio::select! {
-        _ = handle => {}
-        _ = signal::ctrl_c() => {
-            info!("Received Ctrl+C, unmounting gvfs...");
+#[cfg(target_os = "macos")]

Review Comment:
   does macos support fileset fuse ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1945893537


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        location: String,

Review Comment:
   help message like:
   ```
   ./gvfs-fuse mount --help
   Usage: gvfs-fuse mount [OPTIONS] <MOUNT_POINT> <FILESET_LOCATION>
   
   Arguments:
     <MOUNT_POINT>       Mount point for the filesystem
     <FILESET_LOCATION>  The URI of the GVFS fileset, like gvfs://fileset/my_catalog/my_schema/my_fileset
   
   Options:
     -c, --config <CONFIG>  Path to the configuration file
     -d, --debug <DEBUG>    Debug level [default: 0]
     -f, --foreground       Run in foreground
     -h, --help             Print help
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1945893537


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        location: String,

Review Comment:
   help message like:
   ```
   ./gvfs-fuse mount --help
   Usage: gvfs-fuse mount [OPTIONS] <MOUNT_POINT> <FILESET_LOCATION>
   
   Arguments:
     <MOUNT_POINT>       Mount point for the filesystem
     <FILESET_LOCATION>  The URI of the GVFS fileset, like gvfs://fileset/my_catalog/my_schema/my_fileset
   
   Options:
     -c, --config <CONFIG>
     -d, --debug <DEBUG>    Debug level [default: 0]
     -f, --foreground       Run in foreground
     -h, --help             Print help
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1942462187


##########
clients/filesystem-fuse/src/main.rs:
##########
@@ -16,49 +16,214 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-use fuse3::Errno;
+mod command_args;
+
+use crate::command_args::Commands;
+use clap::Parser;
+use daemonize::Daemonize;
 use gvfs_fuse::config::AppConfig;
-use gvfs_fuse::{gvfs_mount, gvfs_unmount};
+use gvfs_fuse::{gvfs_mount, gvfs_unmount, LOG_FILE_NAME, PID_FILE_NAME};
 use log::{error, info};
+use std::fs::{create_dir, OpenOptions};
+use std::io;
+use std::path::Path;
+use std::process::Command;
+use tokio::runtime::Runtime;
 use tokio::signal;
+use tokio::signal::unix::{signal, SignalKind};
 
-#[tokio::main]
-async fn main() -> fuse3::Result<()> {
-    tracing_subscriber::fmt().init();
+fn init_work_dirs(config: &AppConfig, mount_point: &str) -> io::Result<()> {
+    let data_dir_name = Path::new(&config.fuse.data_dir).to_path_buf();
+    let data_dir_name = data_dir_name.canonicalize()?;
+    if !data_dir_name.exists() {
+        Err(io::Error::new(
+            io::ErrorKind::NotFound,
+            format!("Data directory {} not found", &config.fuse.data_dir),
+        ))?
+    };
 
-    // todo need inmprove the args parsing
-    let args: Vec<String> = std::env::args().collect();
-    let (mount_point, mount_from, config_path) = match args.len() {
-        4 => (args[1].clone(), args[2].clone(), args[3].clone()),
-        _ => {
-            error!("Usage: {} <mount_point> <mount_from> <config>", args[0]);
-            return Err(Errno::from(libc::EINVAL));
-        }
+    let mount_point_name = data_dir_name.join(mount_point);
+    if !mount_point_name.exists() {
+        create_dir(&mount_point_name)?
+    };
+
+    let log_dir_name = data_dir_name.join(&config.fuse.log_dir);
+    if !log_dir_name.exists() {
+        create_dir(&log_dir_name)?
     };
 
-    //todo(read config file from args)
-    let config = AppConfig::from_file(Some(&config_path));
-    if let Err(e) = &config {
-        error!("Failed to load config: {:?}", e);
-        return Err(Errno::from(libc::EINVAL));
+    Ok(())
+}
+
+fn make_daemon(config: &AppConfig) -> io::Result<()> {
+    let data_dir_name = Path::new(&config.fuse.data_dir);
+    let log_dir_name = data_dir_name.join(&config.fuse.log_dir);
+    let log_file_name = log_dir_name.join(LOG_FILE_NAME);
+    let log_file = OpenOptions::new()
+        .create(true)
+        .append(true)
+        .open(&log_file_name)
+        .unwrap();
+    let log_err_file = OpenOptions::new().append(true).open(log_file_name).unwrap();
+
+    let pid_file_name = data_dir_name.join(PID_FILE_NAME);
+
+    let daemonize = Daemonize::new()
+        .pid_file(pid_file_name)
+        .chown_pid_file(true)
+        .working_directory(data_dir_name)
+        .stdout(log_file)
+        .stderr(log_err_file);
+
+    match daemonize.start() {
+        Ok(_) => info!("Gvfs-fuse Daemon started successfully"),
+        Err(e) => {
+            return Err(io::Error::new(
+                io::ErrorKind::Other,
+                format!("Gvfs-fuse Daemon failed to start: {:?}", e),
+            ))
+        }
     }
-    let config = config.unwrap();
-    let handle = tokio::spawn(async move {
-        let result = gvfs_mount(&mount_point, &mount_from, &config).await;
-        if let Err(e) = result {
-            error!("Failed to mount gvfs: {:?}", e);
-            return Err(Errno::from(libc::EINVAL));
+    Ok(())
+}
+
+fn mount_fuse(config: AppConfig, mount_point: String, target: String) -> io::Result<()> {
+    let rt = Runtime::new()?;
+    rt.block_on(async {
+        let handle = tokio::spawn(async move {
+            let result = gvfs_mount(&mount_point, &target, &config).await;
+            if let Err(e) = result {
+                error!("Failed to mount gvfs: {:?}", e);
+                return Err(io::Error::from(io::ErrorKind::InvalidInput));
+            }
+            Ok(())
+        });
+
+        let mut term_signal = signal(SignalKind::terminate())?;
+        tokio::select! {
+            _ = handle => {}
+            _ = signal::ctrl_c() => {
+                    info!("Received Ctrl+C, unmounting gvfs...")
+                }
+            _ = term_signal.recv()=> {
+                    info!("Received SIGTERM, unmounting gvfs...")
+                }
         }
+
+        let _ = gvfs_unmount().await;
         Ok(())
-    });
+    })
+}
 
-    tokio::select! {
-        _ = handle => {}
-        _ = signal::ctrl_c() => {
-            info!("Received Ctrl+C, unmounting gvfs...");
+#[cfg(target_os = "macos")]

Review Comment:
   Linux also supported. see the other `do_umount` function



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1942482374


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",

Review Comment:
   fix



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "FANNG1 (via GitHub)" <gi...@apache.org>.
FANNG1 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1945906753


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        location: String,

Review Comment:
    is`FILESET_URI` more meaningful than `FILESET_LOCATION`?



##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "0.1",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "The URI of the GVFS fileset")]
+        fileset_location: String,
+
+        #[arg(short, long)]
+        config: Option<String>,

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [#6320] feat (gvfs-fuse): Support mount and umount command for gvfs-fuse command line tools [gravitino]

Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #6321:
URL: https://github.com/apache/gravitino/pull/6321#discussion_r1921919770


##########
clients/filesystem-fuse/src/command_args.rs:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+use clap::{Parser, Subcommand};
+
+#[derive(Parser, Debug)]
+#[command(
+    name = "gvfs-fuse",
+    version = "1.0",
+    about = "A FUSE-based file system client"
+)]
+pub(crate) struct Arguments {
+    #[command(subcommand)]
+    pub(crate) command: Commands,
+}
+
+#[derive(Subcommand, Debug)]
+pub(crate) enum Commands {
+    Mount {
+        #[arg(help = "Mount point for the filesystem")]
+        mount_point: String,
+
+        #[arg(help = "Location of GVFS fileset URI")]
+        location: String,
+
+        #[arg(short, long)]
+        config: Option<String>,
+
+        #[arg(short, long, help = "Debug level", default_value_t = 0)]
+        debug: u8,

Review Comment:
   Yes, we will need to use this argument in PR #5905.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org