示例#1
0
 def stat(self):
     statobj = Stat(st_ino = self.id, st_uid = os.getuid(), st_gid = os.getgid(), st_size = self.size, st_atime = self.atime, st_mtime = self.mtime, st_ctime = self.ctime, st_nlink = 0)
     if self.kind == FSNODE_FOLDER:
         statobj.st_mode = STAT_UMASK | stat.S_IFDIR
     else:
         statobj.st_mode = STAT_UMASK | stat.S_IFLNK
     return statobj
示例#2
0
 def stat(self):
     statobj = Stat(st_ino=self.id,
                    st_uid=os.getuid(),
                    st_gid=os.getgid(),
                    st_size=self.size,
                    st_atime=self.atime,
                    st_mtime=self.mtime,
                    st_ctime=self.ctime,
                    st_nlink=0)
     if self.kind == FSNODE_FOLDER:
         statobj.st_mode = STAT_UMASK | stat.S_IFDIR
     else:
         statobj.st_mode = STAT_UMASK | stat.S_IFLNK
     return statobj
示例#3
0
文件: adbfs.py 项目: Pasha13666/adbfs
    def getattr(self, path):
        st = Stat()
        st.st_nlink = 1
        if self._sh('test -e "%s"&&echo true' % path).strip() != 'true':
            return -ENOENT

        elif self._sh('test -h "%s"&&echo true' % path).strip() == 'true':
            st.st_mode = stat.S_IFLNK

        elif self._sh('test -d "%s"&&echo true' % path).strip() == 'true':
            st.st_mode = stat.S_IFDIR

        elif self._sh('test -f "%s"&&echo true' % path).strip() == 'true':
            st.st_mode = stat.S_IFREG

        elif self._sh('test -c "%s"&&echo true' % path).strip() == 'true':
            st.st_mode = stat.S_IFCHR

        elif self._sh('test -b "%s"&&echo true' % path).strip() == 'true':
            st.st_mode = stat.S_IFBLK

        elif self._sh('test -p "%s"&&echo true' % path).strip() == 'true':
            st.st_mode = stat.S_IFIFO

        elif self._sh('test -s "%s"&&echo true' % path).strip() == 'true':
            st.st_mode = stat.S_IFSOCK

        else:
            st.st_mode = 0

        st.st_mode |= int(self._sh('stat -c%%a "%s"' % path) or '0', 8)
        st.st_size = int(self._sh('stat -c%%s "%s"' % path) or '0')
        print "file:", path, "size: ", st.st_size, "mode:", oct(st.st_mode)

        return st
示例#4
0
 def pre_getattr(self, path):
     st = Stat()
     pe = getParts(path)
     st.st_mode = stat.S_IFDIR | 0555
     st.st_ino = 0
     st.st_dev = 0
     st.st_nlink = 2
     st.st_uid = 0
     st.st_gid = 0
     st.st_size = 4096
     st.st_atime = 0
     st.st_mtime = 0
     st.st_ctime = 0
     if self.is_root(pathelts=pe):
         return st
     if len(pe) < 3:  # ext dir
         query = "SELECT COUNT(*) FROM files WHERE newname like '{0}%';".format(
             escape_for_sql(pe[-1]))
         try:
             self.DBG(query)
             self.cursor.execute(query)
             cnt = self.cursor.fetchone()
         except Exception as e:
             self.DBG("Whoa, except: {0}".format(str(e)))
             cnt = [0]
         if cnt[0] < 1:
             self.DBG("Nothing returned, ENOENT")
             return -fuse.ENOENT
         return st
     else:
         st.st_mode = stat.S_IFLNK | 0777
         st.st_nlink = 1
         st.st_size = 0
         newname = self.namekey(pe[-1])
         # I guess I should search on the name and not _id, so that
         # using dummy names with real _ids won't work.
         query = "SELECT COUNT(*) FROM files WHERE newname='{0}';".format(
             escape_for_sql(newname))
         try:
             self.DBG(query)
             self.cursor.execute(query)
             cnt = self.cursor.fetchone()
         except Exception as e:
             self.DBG("Whoa, except: {0}".format(e))
             cnt = [0]
         if cnt[0] < 1:
             self.DBG("File not found.")
             return -fuse.ENOENT
     return st
示例#5
0
文件: adbfs.py 项目: Pasha13666/adbfs
 def wrapper(self, path):
     if path in INFO_CACHE:
         st = INFO_CACHE[path]
         f = Stat()
         f.st_nlink = 1
         f.st_mode = st[0]
         f.st_size = st[1]
         return f
     else:
         f = fn(self, path)
         if isinstance(f, Stat):
             INFO_CACHE[path] = (f.st_mode, f.st_size)
         return f
示例#6
0
 def getattr(self):
     st = Stat()
     st.st_size = self.inode.file_size
     st.st_mode = stat.S_IFREG | 0666
     return st
示例#7
0
文件: file.py 项目: chiiph/ESFS
 def getattr(self):
     st = Stat()
     st.st_size = self.inode.file_size
     st.st_mode = stat.S_IFREG | 0666
     return st