Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
stagfs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SexHackMe
stagfs
Commits
0ae2f7ae
Commit
0ae2f7ae
authored
Aug 19, 2023
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start to create structure
parent
d19ce371
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
71 deletions
+101
-71
stagfs.py
stagfs.py
+101
-71
No files found.
stagfs.py
View file @
0ae2f7ae
#!/usr/bin/env python
#!/usr/bin/env python
3
from
__future__
import
print_function
,
absolute_import
,
division
import
logging
import
os
from
errno
import
EACCES
from
os.path
import
realpath
from
threading
import
Lock
from
fusepy
import
FUSE
,
FuseOSError
,
Operations
,
LoggingMixIn
class
Loopback
(
LoggingMixIn
,
Operations
):
def
__init__
(
self
,
root
):
self
.
root
=
realpath
(
root
)
self
.
rwlock
=
Lock
()
def
__init__
(
self
,
root
):
self
.
root
=
realpath
(
root
)
self
.
rwlock
=
Lock
()
def
__call__
(
self
,
op
,
path
,
*
args
):
print
(
op
)
print
(
path
)
if
path
==
'/'
and
op
!=
'init'
:
return
super
(
Loopback
,
self
)
.
__call__
(
'base_'
+
op
,
path
,
*
args
)
if
path
==
'/'
and
op
==
'init'
:
return
super
(
Loopback
,
self
)
.
__call__
(
op
,
path
,
*
args
)
psplit
=
path
.
split
(
'/'
,
2
)
pstart
=
False
if
len
(
psplit
)
>
1
:
pstart
=
psplit
[
1
]
if
pstart
and
pstart
==
'CONTENT'
:
return
super
(
Loopback
,
self
)
.
__call__
(
op
,
self
.
root
+
path
.
replace
(
'/CONTENT'
,
''
),
*
args
)
if
pstart
in
[
'TAGS'
,
'CATEGORIES'
]
and
path
.
replace
(
'/'
+
pstart
,
''
)
==
''
:
return
super
(
Loopback
,
self
)
.
__call__
(
op
,
self
.
root
,
*
args
)
raise
FuseOSError
(
EACCES
)
def
base_destroy
(
self
,
*
args
):
return
self
.
destroy
(
*
args
)
def
access
(
self
,
path
,
mode
):
if
not
os
.
access
(
path
,
mode
):
raise
FuseOSError
(
EACCES
)
chmod
=
os
.
chmod
chown
=
os
.
chown
def
create
(
self
,
path
,
mode
):
return
os
.
open
(
path
,
os
.
O_WRONLY
|
os
.
O_CREAT
|
os
.
O_TRUNC
,
mode
)
#def __call__(self, op, path, *args
):
# return super(Loopback, self).__call__(op, self.root + path, *args
)
def
flush
(
self
,
path
,
fh
):
return
os
.
fsync
(
fh
)
def
access
(
self
,
path
,
mode
):
if
not
os
.
access
(
path
,
mode
):
raise
FuseOSError
(
EACCES
)
def
fsync
(
self
,
path
,
datasync
,
fh
):
if
datasync
!=
0
:
return
os
.
fdatasync
(
fh
)
else
:
return
os
.
fsync
(
fh
)
chmod
=
os
.
chmod
chown
=
os
.
chown
def
getattr
(
self
,
path
,
fh
=
None
):
st
=
os
.
lstat
(
path
)
return
dict
((
key
,
getattr
(
st
,
key
))
for
key
in
(
'st_atime'
,
'st_ctime'
,
'st_gid'
,
'st_mode'
,
'st_mtime'
,
'st_nlink'
,
'st_size'
,
'st_uid'
))
def
create
(
self
,
path
,
mod
e
):
return
os
.
open
(
path
,
os
.
O_WRONLY
|
os
.
O_CREAT
|
os
.
O_TRUNC
,
mode
)
def
base_getattr
(
self
,
path
,
fh
=
Non
e
):
return
{
'st_atime'
:
1692365924.6988926
,
'st_ctime'
:
1692365924.6988926
,
'st_gid'
:
1000
,
'st_mode'
:
16877
,
'st_mtime'
:
1692365924.6988926
,
'st_nlink'
:
2
,
'st_size'
:
0
,
'st_uid'
:
1000
}
def
flush
(
self
,
path
,
fh
):
return
os
.
fsync
(
fh
)
def
base_opendir
(
self
,
path
,
fh
=
None
):
return
0
def
fsync
(
self
,
path
,
datasync
,
fh
):
if
datasync
!=
0
:
return
os
.
fdatasync
(
fh
)
else
:
return
os
.
fsync
(
fh
)
def
base_releasedir
(
self
,
path
,
fh
=
None
):
return
0
def
getattr
(
self
,
path
,
fh
=
None
):
st
=
os
.
lstat
(
path
)
return
dict
((
key
,
getattr
(
st
,
key
))
for
key
in
(
'st_atime'
,
'st_ctime'
,
'st_gid'
,
'st_mode'
,
'st_mtime'
,
'st_nlink'
,
'st_size'
,
'st_uid'
))
getxattr
=
None
getxattr
=
None
def
link
(
self
,
target
,
source
):
return
os
.
link
(
self
.
root
+
source
,
target
)
def
link
(
self
,
target
,
source
):
return
os
.
link
(
self
.
root
+
source
,
target
)
listxattr
=
None
mkdir
=
os
.
mkdir
mknod
=
os
.
mknod
open
=
os
.
open
listxattr
=
None
mkdir
=
os
.
mkdir
mknod
=
os
.
mknod
open
=
os
.
open
def
read
(
self
,
path
,
size
,
offset
,
fh
):
with
self
.
rwlock
:
os
.
lseek
(
fh
,
offset
,
0
)
return
os
.
read
(
fh
,
size
)
def
read
(
self
,
path
,
size
,
offset
,
fh
):
with
self
.
rwlock
:
os
.
lseek
(
fh
,
offset
,
0
)
return
os
.
read
(
fh
,
size
)
def
readdir
(
self
,
path
,
fh
):
return
[
'.'
,
'..'
]
+
os
.
listdir
(
path
)
def
readdir
(
self
,
path
,
fh
):
return
[
'.'
,
'..'
]
+
os
.
listdir
(
path
)
def
base_
readdir
(
self
,
path
,
fh
):
return
[
'.'
,
'..'
,
'CONTENT'
,
'TAGS'
,
'CATEGORIES'
]
readlink
=
os
.
readlink
readlink
=
os
.
readlink
def
release
(
self
,
path
,
fh
):
return
os
.
close
(
fh
)
def
release
(
self
,
path
,
fh
):
return
os
.
close
(
fh
)
def
rename
(
self
,
old
,
new
):
return
os
.
rename
(
old
,
self
.
root
+
new
)
def
rename
(
self
,
old
,
new
):
return
os
.
rename
(
old
,
self
.
root
+
new
)
rmdir
=
os
.
rmdir
rmdir
=
os
.
rmdir
def
statfs
(
self
,
path
):
stv
=
os
.
statvfs
(
path
)
return
dict
((
key
,
getattr
(
stv
,
key
))
for
key
in
(
'f_bavail'
,
'f_bfree'
,
'f_blocks'
,
'f_bsize'
,
'f_favail'
,
'f_ffree'
,
'f_files'
,
'f_flag'
,
'f_frsize'
,
'f_namemax'
))
def
statfs
(
self
,
path
):
stv
=
os
.
statvfs
(
path
)
return
dict
((
key
,
getattr
(
stv
,
key
))
for
key
in
(
'f_bavail'
,
'f_bfree'
,
'f_blocks'
,
'f_bsize'
,
'f_favail'
,
'f_ffree'
,
'f_files'
,
'f_flag'
,
'f_frsize'
,
'f_namemax'
))
def
symlink
(
self
,
target
,
source
):
return
os
.
symlink
(
source
,
target
)
def
symlink
(
self
,
target
,
source
):
return
os
.
symlink
(
source
,
target
)
def
truncate
(
self
,
path
,
length
,
fh
=
None
):
with
open
(
path
,
'r+'
)
as
f
:
f
.
truncate
(
length
)
def
truncate
(
self
,
path
,
length
,
fh
=
None
):
with
open
(
path
,
'r+'
)
as
f
:
f
.
truncate
(
length
)
unlink
=
os
.
unlink
utimens
=
os
.
utime
unlink
=
os
.
unlink
utimens
=
os
.
utime
def
write
(
self
,
path
,
data
,
offset
,
fh
):
with
self
.
rwlock
:
os
.
lseek
(
fh
,
offset
,
0
)
return
os
.
write
(
fh
,
data
)
def
write
(
self
,
path
,
data
,
offset
,
fh
):
with
self
.
rwlock
:
os
.
lseek
(
fh
,
offset
,
0
)
return
os
.
write
(
fh
,
data
)
if
__name__
==
'__main__'
:
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'root'
)
parser
.
add_argument
(
'mount'
)
args
=
parser
.
parse_args
()
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
fuse
=
FUSE
(
Loopback
(
args
.
root
),
args
.
mount
,
foreground
=
True
,
allow_other
=
True
)
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'root'
)
parser
.
add_argument
(
'mount'
)
args
=
parser
.
parse_args
()
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
fuse
=
FUSE
(
Loopback
(
args
.
root
),
args
.
mount
,
foreground
=
True
,
allow_other
=
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment