Index: appfsd.c ================================================================== --- appfsd.c +++ appfsd.c @@ -648,10 +648,12 @@ if (uid >= 0) { retval += uid; retval++; } + APPFS_DEBUG("Looked up inode number for path=%s,uid=%i: %u", path, uid, retval); + return(retval); } /* * Cache Get Path Info lookups for speed @@ -667,10 +669,12 @@ if (pthread_ret != 0) { APPFS_DEBUG("Unable to lock path_info cache mutex !"); return(-1); } + + APPFS_DEBUG("Looking up cache entry for path=%s,uid=%lli...", path, (long long) uid); if (appfs_path_info_cache != NULL) { hash_idx = (appfs_get_path_inode(path, uid)) % appfs_path_info_cache_size; if (appfs_path_info_cache[hash_idx]._cache_path != NULL) { @@ -689,13 +693,13 @@ return(-1); } if (retval == 0) { - APPFS_DEBUG("Cache hit on %s", path); + APPFS_DEBUG("Cache hit on path=%s,uid=%lli", path, (long long) uid); } else { - APPFS_DEBUG("Cache miss on %s", path); + APPFS_DEBUG("Cache miss on path=%s,uid=%lli", path, (long long) uid); } return(retval); } @@ -1021,10 +1025,12 @@ pathinfo->inode = appfs_get_path_inode(path, -1); } else { pathinfo->inode = appfs_get_path_inode(path, fsuid); } + APPFS_DEBUG("Caching inode for path=%s,uid=%lli as %llu (packaged = %i)", path, (long long) fsuid, pathinfo->inode, pathinfo->packaged); + if (retval == 0) { appfs_get_path_info_cache_add(path, fsuid, pathinfo); } else { APPFS_DEBUG("error: Invalid type for \"%s\" from Tcl", path); } @@ -1213,14 +1219,16 @@ if (pathinfo.typeinfo.file.executable) { stbuf->st_mode |= 0111; } - if (pathinfo.typeinfo.file.suidRoot) { - changeOwnerToUserIfPackaged = 0; + if (pathinfo.packaged) { + if (pathinfo.typeinfo.file.suidRoot) { + changeOwnerToUserIfPackaged = 0; - stbuf->st_mode |= 04000; + stbuf->st_mode |= 04000; + } } if (pathinfo.typeinfo.file.worldaccessible) { stbuf->st_mode &= ~077; } @@ -1252,11 +1260,11 @@ retval = -EIO; break; } - if (pathinfo.packaged && changeOwnerToUserIfPackaged) { + if ((pathinfo.packaged && changeOwnerToUserIfPackaged) || (!pathinfo.packaged)) { stbuf->st_uid = appfs_get_fsuid(); stbuf->st_gid = appfs_get_fsgid(); stbuf->st_mode |= 0200; } @@ -2018,11 +2026,11 @@ #endif /** ** Add FUSE arguments which we always supply **/ - fuse_opt_add_arg(args, "-odefault_permissions,fsname=appfs,subtype=appfsd,use_ino,kernel_cache,entry_timeout=0,attr_timeout=0,big_writes,intr,hard_remove"); + fuse_opt_add_arg(args, "-odefault_permissions,fsname=appfs,subtype=appfsd,use_ino,direct_io,entry_timeout=0,attr_timeout=0,big_writes,intr,hard_remove"); if (getuid() == 0) { fuse_opt_parse(args, NULL, NULL, NULL); fuse_opt_add_arg(args, "-oallow_other"); Index: appfsd.tcl ================================================================== --- appfsd.tcl +++ appfsd.tcl @@ -677,10 +677,12 @@ catch { ::appfs::getindex $pathinfo(hostname) ::appfs::getpkgmanifest $pathinfo(hostname) $pathinfo(package_sha1) } + set retval(path_type) $pathinfo(_type) + switch -- $pathinfo(_type) { "toplevel" { set retval(type) directory set retval(childcount) [llength [getchildren $path]] } @@ -754,10 +756,11 @@ } } if {$localpath != "" && [info exists localpathinfo]} { set retval(is_localfile) 1 + unset retval(packaged) catch { set retval(time) $localpathinfo(mtime) switch -- $localpathinfo(type) { "directory" { @@ -839,11 +842,11 @@ proc openpath {path mode} { array set pathinfo [_parsepath $path] if {$pathinfo(_type) != "files"} { - return -code error "invalid type" + return -code error "invalid path type: Got \"$pathinfo(_type)\", need \"files\"" } set localpath [_localpath $pathinfo(package) $pathinfo(hostname) $pathinfo(file)] if {$mode == "create"} { @@ -903,11 +906,11 @@ proc localpath {path} { array set pathinfo [_parsepath $path] if {$pathinfo(_type) != "files"} { - return -code error "invalid type" + return -code error "invalid path type: Got \"$pathinfo(_type)\", need \"files\"" } set localpath [_localpath $pathinfo(package) $pathinfo(hostname) $pathinfo(file)] return $localpath @@ -952,12 +955,12 @@ } proc unlinkpath {path} { array set pathattrs [exists $path] - if {![info exists pathattrs(packaged)]} { - return -code error "invalid type" + if {$pathattrs(path_type) != "files"} { + return -code error "invalid path type: can only delete type \"files\" this is type \"$pathattrs(path_type)\"" } set localpath $pathattrs(localpath) if {$localpath == ""} {