Skip to content

Commit

Permalink
自动创建目录并自动重命名
Browse files Browse the repository at this point in the history
  • Loading branch information
deep-fire committed Dec 9, 2020
1 parent 4626eb6 commit d0e2198
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions fuse/fuse_ll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ struct deviceInfo

std::string get_atf_path()
{
int uid = getuid();
std::string uidstr = std::to_string(uid);
return "/run/user/" + uidstr + "/aft-mtp/";
// int uid = getuid();
// std::string uidstr = std::to_string(uid);
// return "/run/user/" + uidstr + "/aft-mtp/";

std::string home = getenv("HOME");
home += "/aft-mtp/";
return home;
}

namespace
Expand Down Expand Up @@ -799,6 +803,8 @@ namespace
int main(int argc, char **argv)
{
bool claimInterface = true;
bool fsname_defined = false;

for(int i = 1; i < argc; ++i)
{
if (strcmp(argv[i], "-C") == 0)
Expand All @@ -807,6 +813,11 @@ int main(int argc, char **argv)
mtp::g_debug = true;
if (i + 1 < argc && strcmp(argv[i], "-o") == 0 && strcmp(argv[i + 1], "debug") == 0)
mtp::g_debug = true;

if(i + 1 < argc && strcmp(argv[i], "-o") == 0 && (strlen(argv[i + 1]) > strlen("fsname=")) && strncmp(argv[i + 1], "fsname=", strlen("fsname=")) == 0)
{
fsname_defined = true;
}
}

try
Expand Down Expand Up @@ -840,7 +851,24 @@ int main(int argc, char **argv)
system(cmd.c_str());
const char *real_mount_point = dirPath.c_str();

struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
//-o fsname=xx
char *rargv[100];
int rargc = argc;
std::string rfsnamecmd = "fsname=" + info._Manufacturer + info._SerialNumber;
if(rfsnamecmd.empty()) { rfsnamecmd = "fsname=aft-mtp"; }
for(int i = 0; i < argc; ++i) { rargv[i] = argv[i]; }
if(!fsname_defined)
{
rargc += 2;
rargv[rargc - 2] = "-o";
rargv[rargc - 1] = (char*)rfsnamecmd.c_str();
}

for(int i = 0; i < rargc; ++i) { printf("%s ", rargv[i]); }
printf("\n");


struct fuse_args args = FUSE_ARGS_INIT(rargc, rargv);
struct fuse_chan *ch;
char *mountpoint;
int err = -1;
Expand Down

0 comments on commit d0e2198

Please sign in to comment.