adbncfs  0.9.1
Macros | Functions | Variables
adbncfs.cpp File Reference
#include <sstream>
#include <sys/statvfs.h>
#include <execinfo.h>
#include <signal.h>
#include <stdio.h>
#include <pthread.h>
#include "adbncfs.h"
#include "fileInfoCache.h"
#include "spawn.h"
#include "userInfo.h"
#include "mountInfo.h"
Include dependency graph for adbncfs.cpp:

Go to the source code of this file.

Macros

#define DBG(line)   if (fDebug) cout << "--*-- " << line << endl
 
#define INF(line)   cout << "--*-- " << line << endl
 
#define ERR(line)   cerr << "--*-- " << line << endl
 

Functions

static const int iForwardPort (4444)
 Local and remote adb forward port. More...
 
static bool fDebug (false)
 Debug mode as set in initAdbncFs() More...
 
static bool fInReleaseDirCond (false)
 Waited for condition variable. More...
 
static void sig11Handler (int iSig)
 Segmentation fault handler. More...
 
static SpawninitNetCat ()
 Spawns a netcat process on the local host with the local forward port. More...
 
static void destroyNetCat ()
 Kills the netcat process spawned in initNetCat(). More...
 
static void stringReplacer (string &strSource, const string &strFind, const string &strReplace)
 Replace all instances of string strFind with string strReplace in the given string strSource, which is modified in-place. More...
 
static string makeLocalPath (const string &strPath)
 Converts the given android path to a path on the local host. More...
 
static string parent (const string &strPath)
 Returns the parent pathname string of the given strPath. More...
 
static vector< string > tokenize (const string &strData)
 Splits the given data string into tokens. More...
 
static bool fileExists (const char *pcName)
 Tests whether the file or directory denoted by pcName exists on the local host. More...
 
static deque< string > execCommandViaNetCat (const string &strCommand)
 Execute the given command string via netcat. More...
 
static deque< string > execProg (const char *const argv[], const bool fUseStdErr=false, int *const piError=NULL)
 Execute a program. More...
 
static deque< string > adbncShell (const string &strCommand)
 Execute a shell command on the android device. More...
 
static int adbncPushPullCmd (const bool fPush, const string &strLocalPath, const string &strRemotePath)
 Execute an adb push or pull command with given paths. More...
 
static int adbncPull (const string &strRemoteSource, const string &strLocalDestination)
 Copy (using adb pull) a file from the Android device to the local host. More...
 
int adbncPush (const string &strLocalSource, const string &strRemoteDestination)
 Copy (using adb push) a file from the local host to the Android device. More...
 
static int doStat (const char *pcPath, vector< string > *pOutputTokens=NULL)
 Execute a stat command on android file or directory denoted by pcPath. More...
 
static const string androidNetCatStartCommand ()
 Return the command line used to start netcat process on android device. More...
 
static int androidNetcatStarted ()
 Test if netcat is started on the android device. More...
 
static void androidKillNetCat ()
 Kills the running netcat process on android device. More...
 
static int androidStartNetcat ()
 Starts a netcat process on the android device. More...
 
static int isAndroidDeviceConnected ()
 Tests if any android device is connected to a local host's usb port. More...
 
static bool isAndroidPortForwarded (const string &strForwardArg)
 Tests if tcp socket connections from local port to remote port on the android device is in place. More...
 
static int setAndroidPortForwarding ()
 Enable adb port forwarding for our local and remote port. More...
 
static bool removeAndroidPortForwarding ()
 Tries to remove android port forwarding. More...
 
static void cleanupTempDir (void)
 Recursively deletes the temporary directory created in makeTempDir(). More...
 
static int makeTempDir (void)
 Create a temporary directory and stores the path in strTempDirPath variable. More...
 
static int queryUserInfo ()
 Query user information (uid, gid, groups) form android device. More...
 
static int queryMountInfo ()
 Query mount information form android device. More...
 
int initAdbncFs (const int argc, char **const argv)
 Initialize the file system application. More...
 
void * adbnc_init (struct fuse_conn_info *pConn)
 FUSE callback function to initialize the file system. More...
 
void adbnc_destroy (void *private_data)
 FUSE callback function, called when the file system exits. More...
 
int adbnc_statfs (const char *pcPath, struct statvfs *pFst)
 FUSE callback function to retrieve statistics about the file system. More...
 
int adbnc_getattr (const char *pcPath, struct stat *pStatBuf)
 FUSE callback function to retrieve file attributes. More...
 
int adbnc_open (const char *pcPath, struct fuse_file_info *pFi)
 FUSE callback to open a file. More...
 
int adbnc_opendir (const char *pcPath, struct fuse_file_info *pFi)
 FUSE callback to open a directory for reading. More...
 
int adbnc_readdir (const char *pcPath, void *vpBuf, fuse_fill_dir_t filler, off_t iOffset, struct fuse_file_info *pFi)
 FUSE callback to retrieve directory entries. More...
 
int adbnc_releasedir (const char *pcPath, struct fuse_file_info *pFi)
 FUSE callback to release given directory. More...
 
int adbnc_readlink (const char *pcPath, char *pcBuf, size_t iSize)
 FUSE callback function to resolve a link. More...
 
int adbnc_access (const char *pcPath, int iMask)
 FUSE callback to check whether file pcPath can be accessed. More...
 
int adbnc_flush (const char *pcPath, struct fuse_file_info *pFi)
 FUSE callback function called on each close so that the file system has a chance to report delayed errors. More...
 
int adbnc_fsync (const char *pcPath, int iIsdatasync, struct fuse_file_info *pFi)
 
int adbnc_release (const char *pcPath, struct fuse_file_info *pFi)
 FUSE callback called when FUSE is completely done with a file. More...
 
int adbnc_read (const char *pcPath, char *pcBuf, size_t iSize, off_t iOffset, struct fuse_file_info *pFi)
 FUSE callback to read iSize bytes from the given file into the buffer pcBuf, beginning at iOffset bytes into the file. More...
 
int adbnc_write (const char *pcPath, const char *pcBuf, size_t iSize, off_t iOffset, struct fuse_file_info *pFi)
 
int adbnc_utimens (const char *pcPath, const struct timespec ts[2])
 
int adbnc_truncate (const char *pcPath, off_t iSize)
 
int adbnc_mknod (const char *pcPath, mode_t mode, dev_t rdev)
 
int adbnc_mkdir (const char *pcPath, mode_t mode)
 
int adbnc_rename (const char *pcFrom, const char *pcTo)
 
int adbnc_rmdir (const char *pcPath)
 
int adbnc_unlink (const char *pcPath)
 FUSE callback function to remove (delete) the given file, symbolic link, hard link, or special node. More...
 

Variables

static const char * pcDone = "---eoc---"
 
static const char * pcTempDirTemplate = "/tmp/adbncfs-XXXXXX"
 Template used to makeTempDir() More...
 
static const char * pcSdCardMountEntry = "sdcardfs on /storage/emulated/legacy type sdcardfs (rw,nosuid,nodev,relatime,uid=1023,gid=1023)"
 Big Hack, don't now how to figure out wher sdcard on a phone is mounted. More...
 
static string strTempDirPath
 Path to the temporary directory used by the instance of this application initialized in makeTempDir(). More...
 
static SpawnpNetCat = NULL
 Pointer to the netcat process initialized in initNetCat() More...
 
static FileCache fileCache
 
static FileStatus fileStatus
 
static map< string, deque
< string > > 
openDirs
 Map to store directory listing retrieved with adbnc_opendir() from android device. More...
 
static UserInfopUserInfo = NULL
 Pointer to user info instance initialized in queryUserInfo() More...
 
static MountInfopMountInfo = NULL
 Pointer to mount info instance initialized in queryMountInfo() More...
 
static pthread_mutex_t ncCmdMutex
 Mutex to synchronize thread access to execCommandViaNetCat() More...
 
static pthread_mutex_t openMutex
 Mutex to synchronize thread access to adbnc_open() More...
 
static pthread_mutex_t inReleaseDirMutex
 Mutex to synchronize thread access to adbnc_opendir() and adbnc_releasedir() More...
 
static pthread_cond_t inReleaseDirCond
 Condition to block adbnc_opendir() until adbnc_releasedir() is finished. More...
 

Macro Definition Documentation

#define DBG (   line)    if (fDebug) cout << "--*-- " << line << endl

Definition at line 37 of file adbncfs.cpp.

#define ERR (   line)    cerr << "--*-- " << line << endl

Definition at line 39 of file adbncfs.cpp.

#define INF (   line)    cout << "--*-- " << line << endl

Definition at line 38 of file adbncfs.cpp.

Function Documentation

int adbnc_access ( const char *  pcPath,
int  iMask 
)

FUSE callback to check whether file pcPath can be accessed.

No need to follow links, pcPath never points to a link.

Parameters
pcPathpathname for that access is tested.
iMaskspecifies the accessibility check(s) to be performed, and is either the value F_OK, or a mask consisting of the bitwise OR of one or more of R_OK, W_OK, and X_OK. F_OK tests for the existence of the file. R_OK, W_OK, and X_OK test whether the file exists and grants read, write, and execute permissions, respectively.
Returns
it returns -ENOENT if the path doesn't exist, -EACCESS if the requested permission isn't available, or 0 for success.

Definition at line 1474 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void adbnc_destroy ( void *  private_data)

FUSE callback function, called when the file system exits.

Parameters
private_datacomes from the return value of adbnc_init().

Definition at line 1003 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_flush ( const char *  pcPath,
struct fuse_file_info *  pFi 
)

FUSE callback function called on each close so that the file system has a chance to report delayed errors.

Important: I noticed flush calls for already closed files which causes fsync() to return a EBADF, we'll ignore this error.

Parameters
pcPathpath to the file to be flushed.
pFipFi-fd the file descriptor of the file to flush.
Returns
0 if success -errno otherwise but never EBADF.

Definition at line 1541 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_fsync ( const char *  pcPath,
int  iIsdatasync,
struct fuse_file_info *  pFi 
)

Definition at line 1566 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_getattr ( const char *  pcPath,
struct stat *  pStatBuf 
)

FUSE callback function to retrieve file attributes.

For the given pathname, the elements of the "stat" structure are filled.

Parameters
pcPath
pStatBufis described in detail in the stat(2) manual page.
Returns

Definition at line 1143 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void* adbnc_init ( struct fuse_conn_info *  pConn)

FUSE callback function to initialize the file system.

One-time setup of ncCmdMutex, openMutex, inReleaseDirMutex and inReleaseDirCond.

Parameters
pConngives information about what features are supported by FUSE.
Returns
NULL.

Definition at line 975 of file adbncfs.cpp.

Here is the caller graph for this function:

int adbnc_mkdir ( const char *  pcPath,
mode_t  mode 
)

Definition at line 1710 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_mknod ( const char *  pcPath,
mode_t  mode,
dev_t  rdev 
)

Definition at line 1687 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_open ( const char *  pcPath,
struct fuse_file_info *  pFi 
)

FUSE callback to open a file.

Calls adbncPull() to copy the file from the android device to local host and opens the file on local host. The file handle obtained from local open is set to pFi->fh;

Parameters
pcPathpath to the filename to open.
pFipFi->fh receives the file handle if file could be opened successfully otherwise it is set to -1.
Returns
-errno in case of an error, zero otherwise.

Definition at line 1220 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_opendir ( const char *  pcPath,
struct fuse_file_info *  pFi 
)

FUSE callback to open a directory for reading.

Stores directory content retrieved from android device in openDirs map for retrieval in adbnc_readdir().

Parameters
pcPathpathname of the directory to open.
pFinot used here.
Returns
-EIO if failed to retrieve directory from android device, zero otherwise.

Definition at line 1263 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_read ( const char *  pcPath,
char *  pcBuf,
size_t  iSize,
off_t  iOffset,
struct fuse_file_info *  pFi 
)

FUSE callback to read iSize bytes from the given file into the buffer pcBuf, beginning at iOffset bytes into the file.

Parameters
pcPathpath of the filename to read from.
pcBufreceives the read bytes.
iSizenumber of bytes to read.
iOffsetstart reading at this offset.
pFipFi->fh the file handle of the file to read from. as provided by adbnc_open().
Returns
Returns the number of bytes transferred or -errno in case of an error.

Definition at line 1619 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_readdir ( const char *  pcPath,
void *  vpBuf,
fuse_fill_dir_t  filler,
off_t  iOffset,
struct fuse_file_info *  pFi 
)

FUSE callback to retrieve directory entries.

openDirs, filled by adbnc_opendir(), is supposed to hold the directory listing.

Parameters
pcPathpathname of the directory get the listing from.
vpBufbuffer where result is returned.
fillerFUSE provided helper function for putting directory entries into the result buffer.
iOffsetstart reading form this directory entry.
pFinot used here.
Returns
-EBADF if directory listing was not found in openDirs, zero otherwise.

Definition at line 1311 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_readlink ( const char *  pcPath,
char *  pcBuf,
size_t  iSize 
)

FUSE callback function to resolve a link.

If path is a symbolic link, fills pcBuf with its target, up to iSize.

Parameters
pcPathpathname of the link.
pcBufreceives the target name of the link.
iSizesize of pcBuf.
Returns
-ENOENT if pathname does not exist on android device, -ENOSYS if provided pcBuf is to small for the target name, zero otherwise.

Definition at line 1400 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_release ( const char *  pcPath,
struct fuse_file_info *  pFi 
)

FUSE callback called when FUSE is completely done with a file.

Closes the file handle.

Parameters
pcPathpath of the filename close.
pFipFi->fh the file handle of the file to close as provided by adbnc_open().
Returns
0 if successfully closed, -EBADF if file handle is invalid or -errno i case of an close error.

Definition at line 1598 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_releasedir ( const char *  pcPath,
struct fuse_file_info *  pFi 
)

FUSE callback to release given directory.

Erases the directory listing entry in openDirs.

Parameters
pcPathpathname to the directory to release.
pFinot used here.
Returns
always zero;

Definition at line 1366 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_rename ( const char *  pcFrom,
const char *  pcTo 
)

Definition at line 1725 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_rmdir ( const char *  pcPath)

Definition at line 1754 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_statfs ( const char *  pcPath,
struct statvfs *  pFst 
)

FUSE callback function to retrieve statistics about the file system.

this is how programs like df determine the free space.

Parameters
pcPathstatistic is retrieved for the file system containing this path.
pFstSee statvfs(2) for a description of the structure contents.
Returns
zero on success, non zero otherwise.

Definition at line 1041 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_truncate ( const char *  pcPath,
off_t  iSize 
)

Definition at line 1663 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_unlink ( const char *  pcPath)

FUSE callback function to remove (delete) the given file, symbolic link, hard link, or special node.

Note that if you support hard links, unlink only deletes the data when the last hard link is removed. See unlink(2) for details.

Parameters
pcPathoath to filename to unlink.
Returns
0 if success, -errno otherwise.

Definition at line 1781 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_utimens ( const char *  pcPath,
const struct timespec  ts[2] 
)

Definition at line 1648 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbnc_write ( const char *  pcPath,
const char *  pcBuf,
size_t  iSize,
off_t  iOffset,
struct fuse_file_info *  pFi 
)

Definition at line 1637 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int adbncPull ( const string &  strRemoteSource,
const string &  strLocalDestination 
)
static

Copy (using adb pull) a file from the Android device to the local host.

Parameters
strRemoteSourceAndroid-side file path to copy.
strLocalDestinationlocal host-side destination path for copy.
Returns
0 if no error, non zero otherwise.
See also
adbncPush.
adbncPushPullCmd.
Bug:
problems with files with ? in filenames (adb bug?)

Definition at line 512 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int adbncPush ( const string &  strLocalSource,
const string &  strRemoteDestination 
)

Copy (using adb push) a file from the local host to the Android device.

Very similar to adbnc_pull().

Returns
0 if no error, non zero otherwise.
See also
adbncPull.
adbncPushPullCmd.
Bug:
problems with files with ? in filenames (adb bug?).

Definition at line 528 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int adbncPushPullCmd ( const bool  fPush,
const string &  strLocalPath,
const string &  strRemotePath 
)
static

Execute an adb push or pull command with given paths.

Parameters
fPushtrue for a push command, false for pull.
strLocalPathpath on local host for push or pull command.
strRemotePathpath on remote device for push or pull command.
Returns
0 if no error, non zero otherwise
See also
adbncPull.
adbncPush.

Definition at line 462 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static deque<string> adbncShell ( const string &  strCommand)
static

Execute a shell command on the android device.

The given string command is prefixed with "busybox ".

Parameters
strCommandthe command to execute.
Returns
the queue of lines written to stdout by the executed command.
See also
execCommandViaNetCat.

Definition at line 445 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void androidKillNetCat ( )
static

Kills the running netcat process on android device.

See also
androidStartNetcat.

Definition at line 636 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static const string androidNetCatStartCommand ( )
static

Return the command line used to start netcat process on android device.

Returns
nc -ll -p forwardport -e /system/xbin/bash
See also
androidStartNetcat

Definition at line 595 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int androidNetcatStarted ( )
static

Test if netcat is started on the android device.

Returns
pid of netcat or 0 if not started.

Definition at line 608 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int androidStartNetcat ( )
static

Starts a netcat process on the android device.

Returns
0 if netcat could successfully be started, 3 otherwise.
See also
androidNetCatStartCommand.

Definition at line 661 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void cleanupTempDir ( void  )
static

Recursively deletes the temporary directory created in makeTempDir().

Definition at line 806 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void destroyNetCat ( )
static

Kills the netcat process spawned in initNetCat().

Definition at line 166 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int doStat ( const char *  pcPath,
vector< string > *  pOutputTokens = NULL 
)
static

Execute a stat command on android file or directory denoted by pcPath.

Parameters
pcPathpathname of file or directory on android device.
pOutputTokensif not NULL receives the tokenized output of the stat. command.
Returns
-ENOENT if pcPath does not exists, zero otherwise.

Definition at line 542 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static deque<string> execCommandViaNetCat ( const string &  strCommand)
static

Execute the given command string via netcat.

Parameters
strCommandthe string to be executed as a command.
Returns
the queue of lines written to stdout by the executed command.

Definition at line 314 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static deque<string> execProg ( const char *const  argv[],
const bool  fUseStdErr = false,
int *const  piError = NULL 
)
static

Execute a program.

If program could not be started or if no pipe could be created. an error message is printed to stderr and if piError is not null error number is returned in *piError.

Parameters
argvan array of pointers to null-terminated strings that represent the argument list available to the new program. The first argument, by convention, must point to the filename associated with the file being executed. The array of pointers must be terminated by a NULL pointer.
fUseStdErrif true stderr is redirected instead of stdout.
piErrorreceives, if not NULL,exit code of the program or an errno if an error occurred starting the program.
Returns
the queue of lines written to stdout respectively stderr by the executed program.

Definition at line 362 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static bool fDebug ( false  )
static

Debug mode as set in initAdbncFs()

Here is the caller graph for this function:

static bool fileExists ( const char *  pcName)
static

Tests whether the file or directory denoted by pcName exists on the local host.

Parameters
pcNamethe pathname to test for existence.
Returns
true if and only if the file or directory denoted by pcName exists; false otherwise

Definition at line 301 of file adbncfs.cpp.

Here is the caller graph for this function:

static bool fInReleaseDirCond ( false  )
static

Waited for condition variable.

Here is the caller graph for this function:

static const int iForwardPort ( 4444  )
static

Local and remote adb forward port.

Here is the caller graph for this function:

int initAdbncFs ( const int  argc,
char **const  argv 
)

Initialize the file system application.

Returns
0 if a device is connected and no other error occurred; a value != 0 otherwise.

Definition at line 906 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static Spawn& initNetCat ( )
static

Spawns a netcat process on the local host with the local forward port.

Writes the used start command to stdout.

Returns
a reference to the spawned netcat process is returned.

Definition at line 140 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int isAndroidDeviceConnected ( )
static

Tests if any android device is connected to a local host's usb port.

Returns
0 if a device is connected; 1 otherwise.

Definition at line 683 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static bool isAndroidPortForwarded ( const string &  strForwardArg)
static

Tests if tcp socket connections from local port to remote port on the android device is in place.

Parameters
strForwardArgthe local and remote port to be used for testing. e.g. "tcp:4444 tcp:4444"
Returns
true if and only if adb port forwarding is in place; false otherwise.
See also
setAndroidPortForwarding

Definition at line 721 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static string makeLocalPath ( const string &  strPath)
static

Converts the given android path to a path on the local host.

Parameters
strPaththe path as used on the android device.
Returns
the path used on the local host within strTempDirPath
See also
pcTempDirTemplate
makeTempDir()

Definition at line 210 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int makeTempDir ( void  )
static

Create a temporary directory and stores the path in strTempDirPath variable.

Returns
errno if an error occurred or 0 otherwise.
See also
acTempDirTemplate

Definition at line 819 of file adbncfs.cpp.

Here is the caller graph for this function:

static string parent ( const string &  strPath)
static

Returns the parent pathname string of the given strPath.

The parent of strPath consists of the pathname's prefix, if any, and each name in the strPath name sequence except for the last.

Parameters
strPaththe pathname thats parent to retrieve.
Returns
The pathname string of the parent directory named by strPath

strip last slash if there is one

Definition at line 229 of file adbncfs.cpp.

Here is the caller graph for this function:

static int queryMountInfo ( )
static

Query mount information form android device.

A "adb shell busybox mount" command is executed and the output is stored in a MontInfo instance for later retrieval. A pointer to the MontInfo object is stored in pMountInfo.

If command failed en error message is written to stdout

Returns
0 if mount information is obtained, 1 otherwise.

Definition at line 870 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int queryUserInfo ( )
static

Query user information (uid, gid, groups) form android device.

A "adb shell busybox id" command is executed and the output is stored in a UserInfo instance for later retrieval. A pointer to the UserInfo object is stored in pUserInfo.

If command failed en error message is written to stdout

Returns
0 if user information is obtained, 1 otherwise.

Definition at line 845 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static bool removeAndroidPortForwarding ( )
static

Tries to remove android port forwarding.

Returns
true if and only if adb port forwarding for our local and remote port is removed; false otherwise.
See also
setAndroidPortForwarding.

Definition at line 780 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static int setAndroidPortForwarding ( )
static

Enable adb port forwarding for our local and remote port.

Returns
0 if port forwarding could be enabled, 2 otherwise.

Definition at line 745 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void sig11Handler ( int  iSig)
static

Segmentation fault handler.

Is installed in initAdbncFs()

Parameters
iSigis supposed to be SIGSEGV.
See also
initAdbncFs

Definition at line 119 of file adbncfs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void stringReplacer ( string &  strSource,
const string &  strFind,
const string &  strReplace 
)
static

Replace all instances of string strFind with string strReplace in the given string strSource, which is modified in-place.

The work proceeds down the string and skips over the text introduced by the replacement.

Parameters
strSourcethe string to be modified.
strFindthe pattern to be replaced.
strReplacethe replacement for strFind.

Definition at line 189 of file adbncfs.cpp.

Here is the caller graph for this function:

static vector<string> tokenize ( const string &  strData)
static

Splits the given data string into tokens.

The vector returned by this function contains each substring of the data string that is terminated by

\t

, or blank by the end of the data string.

The substrings in the vector are in the order in which they occur in the data string. If no blank or

\t

, is in the data string then the resulting vector has just one element, namely the data string.

Parameters
strDatathe string to split around blanks and tabs.
Returns
a vector of tokens

Definition at line 271 of file adbncfs.cpp.

Here is the caller graph for this function:

Variable Documentation

FileCache fileCache
static

Definition at line 77 of file adbncfs.cpp.

FileStatus fileStatus
static

Definition at line 78 of file adbncfs.cpp.

pthread_cond_t inReleaseDirCond
static

Condition to block adbnc_opendir() until adbnc_releasedir() is finished.

Definition at line 106 of file adbncfs.cpp.

pthread_mutex_t inReleaseDirMutex
static

Mutex to synchronize thread access to adbnc_opendir() and adbnc_releasedir()

Definition at line 101 of file adbncfs.cpp.

pthread_mutex_t ncCmdMutex
static

Mutex to synchronize thread access to execCommandViaNetCat()

Definition at line 93 of file adbncfs.cpp.

map<string, deque<string> > openDirs
static

Map to store directory listing retrieved with adbnc_opendir() from android device.

Key is the pathname to the directory.

Definition at line 84 of file adbncfs.cpp.

pthread_mutex_t openMutex
static

Mutex to synchronize thread access to adbnc_open()

Definition at line 96 of file adbncfs.cpp.

const char* pcDone = "---eoc---"
static

Definition at line 53 of file adbncfs.cpp.

const char* pcSdCardMountEntry = "sdcardfs on /storage/emulated/legacy type sdcardfs (rw,nosuid,nodev,relatime,uid=1023,gid=1023)"
static

Big Hack, don't now how to figure out wher sdcard on a phone is mounted.

Todo:
figure out how to get this information from the device.

Definition at line 63 of file adbncfs.cpp.

const char* pcTempDirTemplate = "/tmp/adbncfs-XXXXXX"
static

Template used to makeTempDir()

Definition at line 56 of file adbncfs.cpp.

MountInfo* pMountInfo = NULL
static

Pointer to mount info instance initialized in queryMountInfo()

Definition at line 90 of file adbncfs.cpp.

Spawn* pNetCat = NULL
static

Pointer to the netcat process initialized in initNetCat()

Definition at line 75 of file adbncfs.cpp.

UserInfo* pUserInfo = NULL
static

Pointer to user info instance initialized in queryUserInfo()

Definition at line 87 of file adbncfs.cpp.

string strTempDirPath
static

Path to the temporary directory used by the instance of this application initialized in makeTempDir().

Definition at line 69 of file adbncfs.cpp.