Skip to content

Commit

Permalink
Fix multiple server mount (#41)
Browse files Browse the repository at this point in the history
* Use subdirectory to mount with server name

* Fix windows function compiler error

* Fix using no_gui options
  • Loading branch information
jfantinhardesty authored Aug 7, 2024
1 parent 388c34d commit 45bd331
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 86 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ jobs:
if: ${{ Contains(matrix.os, 'windows') }}
shell: pwsh
run: |
$download_url = Invoke-RestMethod -Uri "https://api.github.com/repos/Seagate/cloudfuse/releases/latest" | Select-Object -ExpandProperty assets | Where-Object { $_.name -like "*no_gui_windows_amd64.exe" } | Select-Object -ExpandProperty browser_download_url
$download_url = Invoke-RestMethod -Uri "https://api.github.com/repos/Seagate/cloudfuse/releases/latest" | Select-Object -ExpandProperty assets | Where-Object { $_.name -like "*no_gui" -and $_.name -like "*windows_amd64.exe" } | Select-Object -ExpandProperty browser_download_url
$file_name = $download_url.Split('/')[-1]
Invoke-WebRequest -Uri $download_url -OutFile $file_name
- name: Download cloudfuse for Linux amd64 (no_gui)
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: |
download_url=$(curl -s https://api.github.com/repos/Seagate/cloudfuse/releases/latest | jq -r '.assets[] | select(.name | contains("no_gui_linux_amd64.deb")) | .browser_download_url')
download_url=$(curl -s https://api.github.com/repos/Seagate/cloudfuse/releases/latest | jq -r '.assets[] | select(.name | (contains("no_gui") and contains("linux_amd64.deb"))) | .browser_download_url')
curl -LO $download_url
- name: Download cloudfuse for Linux arm64 (no_gui)
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: |
download_url=$(curl -s https://api.github.com/repos/Seagate/cloudfuse/releases/latest | jq -r '.assets[] | select(.name | contains("no_gui_linux_arm64.deb")) | .browser_download_url')
download_url=$(curl -s https://api.github.com/repos/Seagate/cloudfuse/releases/latest | jq -r '.assets[] | select(.name | (contains("no_gui") and contains("linux_arm64.deb"))) | .browser_download_url')
curl -LO $download_url
- name: Run build script for Linux x64
Expand Down
91 changes: 51 additions & 40 deletions src/lib/cloudfuse/child_process_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,60 @@
#include "child_process.h"
#include <fstream>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <unistd.h>

std::string config_template = R"(
allow-other: true
logging:
level: log_err
type: syslog
components:
- libfuse
- file_cache
- attr_cache
- s3storage
libfuse:
attribute-expiration-sec: 1800
entry-expiration-sec: 1800
negative-entry-expiration-sec: 1800
ignore-open-flags: true
network-share: true
file_cache:
path: { 0 }
timeout-sec: 180
allow-non-empty-temp: true
cleanup-on-start: false
attr_cache:
timeout-sec: 3600
s3storage:
bucket-name: { BUCKET_NAME }
endpoint: { ENDPOINT }
region: { AWS_REGION }
)";
std::string getSystemName()
{
std::string systemName;
struct utsname buffer;
if (uname(&buffer) != -1)
{
systemName = buffer.nodename;
}

return systemName;
}

CloudfuseMngr::CloudfuseMngr()
{
std::string systemName = getSystemName();
std::string config_template = R"(
allow-other: true
logging:
level: log_err
type: syslog
components:
- libfuse
- file_cache
- attr_cache
- s3storage
libfuse:
attribute-expiration-sec: 1800
entry-expiration-sec: 1800
negative-entry-expiration-sec: 1800
ignore-open-flags: true
network-share: true
file_cache:
path: { 0 }
timeout-sec: 180
allow-non-empty-temp: true
cleanup-on-start: false
attr_cache:
timeout-sec: 3600
s3storage:
bucket-name: { BUCKET_NAME }
endpoint: { ENDPOINT }
region: { AWS_REGION }
subdirectory: )" + systemName +
"\n";

std::string homeEnv;
const char *home = std::getenv("HOME");
if (home == nullptr)
Expand All @@ -80,13 +95,9 @@ CloudfuseMngr::CloudfuseMngr()
configFile = homeEnv + "/nx_plugin_config.aes";
templateFile = homeEnv + "/nx_plugin_config.yaml";

std::ifstream in(templateFile);
if (!in.good())
{
std::ofstream out(templateFile);
out << config_template;
out.close();
}
std::ofstream out(templateFile, std::ios::trunc);
out << config_template;
out.close();
}

processReturn CloudfuseMngr::spawnProcess(char *const argv[], char *const envp[])
Expand Down
97 changes: 54 additions & 43 deletions src/lib/cloudfuse/child_process_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,42 +41,6 @@ namespace fs = std::filesystem;
#include <fstream>
#include <locale>

std::string config_template = R"(
allow-other: true
logging:
level: log_err
type: syslog
components:
- libfuse
- file_cache
- attr_cache
- s3storage
libfuse:
attribute-expiration-sec: 1800
entry-expiration-sec: 1800
negative-entry-expiration-sec: 1800
ignore-open-flags: true
network-share: true
file_cache:
path: { 0 }
timeout-sec: 180
allow-non-empty-temp: true
cleanup-on-start: false
attr_cache:
timeout-sec: 3600
s3storage:
key-id: { AWS_ACCESS_KEY_ID }
secret-key: { AWS_SECRET_ACCESS_KEY }
bucket-name: { BUCKET_NAME }
endpoint: { ENDPOINT }
region: { AWS_REGION }
)";

// Return available drive letter to mount
std::string getAvailableDriveLetter()
{
Expand All @@ -91,8 +55,59 @@ std::string getAvailableDriveLetter()
return "Z:";
}

std::string getSystemName()
{
std::string systemName;
char computerName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = sizeof(computerName) / sizeof(char);
if (GetComputerNameA(computerName, &size))
{
systemName = computerName;
}

return systemName;
}

CloudfuseMngr::CloudfuseMngr()
{
std::string systemName = getSystemName();
std::string config_template = R"(
allow-other: true
logging:
level: log_err
type: syslog
components:
- libfuse
- file_cache
- attr_cache
- s3storage
libfuse:
attribute-expiration-sec: 1800
entry-expiration-sec: 1800
negative-entry-expiration-sec: 1800
ignore-open-flags: true
network-share: true
file_cache:
path: { 0 }
timeout-sec: 180
allow-non-empty-temp: true
cleanup-on-start: false
attr_cache:
timeout-sec: 3600
s3storage:
key-id: { AWS_ACCESS_KEY_ID }
secret-key: { AWS_SECRET_ACCESS_KEY }
bucket-name: { BUCKET_NAME }
endpoint: { ENDPOINT }
region: { AWS_REGION }
subdirectory: )" + systemName +
"\n";

std::string appdataEnv;
char *buf = nullptr;
size_t len;
Expand All @@ -116,13 +131,9 @@ CloudfuseMngr::CloudfuseMngr()
configFile = configFilePath.generic_string();
templateFile = templateFilePath.generic_string();

std::ifstream in(templateFile.c_str());
if (!in.good())
{
std::ofstream out(templateFile.c_str());
out << config_template;
out.close();
}
std::ofstream out(templateFile, std::ios::trunc);
out << config_template;
out.close();
}

processReturn CloudfuseMngr::spawnProcess(wchar_t *argv, std::wstring envp)
Expand Down

0 comments on commit 45bd331

Please sign in to comment.