diff --git a/adbfs.cpp b/adbfs.cpp index 11bcbf5..cafd69b 100644 --- a/adbfs.cpp +++ b/adbfs.cpp @@ -80,6 +80,7 @@ #include #include #include +#include void handler(int sig) { void *array[10]; @@ -942,6 +943,49 @@ static int adb_readlink(const char *path, char *buf, size_t size) return 0; } +static int adb_chmod(const char* path, mode_t mode) +{ + char mode_c[4]; + sprintf(mode_c, "%3o", mode&0777); + + string path_string; + path_string.assign(path); + shell_escape_path(path_string); + + string command = "chmod "; + command.append(mode_c); + command.append(" "); + command.append(path_string); + + adb_shell(command); + invalidateCache(string(path)); + return 0; +} +static int adb_chown(const char* path, uid_t uid, gid_t gid) +{ + char uid_c[10]; + char gid_c[10]; + + sprintf(uid_c, "%i", uid); + sprintf(gid_c, "%i", gid); + + string path_string; + path_string.assign(path); + shell_escape_path(path_string); + + string command = "chown "; + command.append(uid_c); + command.append("."); + command.append(gid_c); + command.append(" "); + command.append(path_string); + + adb_shell(command); + invalidateCache(string(path)); + return 0; +} + + /** Main struct for FUSE interface. */ @@ -974,6 +1018,8 @@ int main(int argc, char *argv[]) adbfs_oper.rmdir = adb_rmdir; adbfs_oper.unlink = adb_unlink; adbfs_oper.readlink = adb_readlink; + adbfs_oper.chmod = adb_chmod; + adbfs_oper.chown = adb_chown; adb_shell("ls"); return fuse_main(argc, argv, &adbfs_oper, NULL); }