當前位置: 首頁>>代碼示例>>Python>>正文


Python stat.S_IFCHR屬性代碼示例

本文整理匯總了Python中stat.S_IFCHR屬性的典型用法代碼示例。如果您正苦於以下問題:Python stat.S_IFCHR屬性的具體用法?Python stat.S_IFCHR怎麽用?Python stat.S_IFCHR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在stat的用法示例。


在下文中一共展示了stat.S_IFCHR屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_unix_target

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFCHR [as 別名]
def test_unix_target(self):

        inode = 42
        self.db.execute("INSERT INTO inodes (id, mode,uid,gid,mtime_ns,atime_ns,ctime_ns,refcount) "
                     "VALUES (?,?,?,?,?,?,?,?)",
                     (inode, stat.S_IFCHR | stat.S_IRUSR | stat.S_IWUSR,
                      os.getuid(), os.getgid(), time_ns(), time_ns(), time_ns(), 1))
        self._link(b'test-entry', inode)

        self.fsck.found_errors = False
        self.fsck.check_unix()
        self.assertFalse(self.fsck.found_errors)

        self.db.execute('INSERT INTO symlink_targets (inode, target) VALUES(?,?)', (inode, 'foo'))
        self.fsck.check_unix()
        self.assertTrue(self.fsck.found_errors) 
開發者ID:s3ql,項目名稱:s3ql,代碼行數:18,代碼來源:t3_fsck.py

示例2: restore

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFCHR [as 別名]
def restore(self, fileContents, root, target, journal=None, nameLookup=True,
                **kwargs):
        util.removeIfExists(target)

        if not journal and os.getuid(): return target

        util.mkdirChain(os.path.dirname(target))

        if journal:
            journal.mknod(root, target, self.lsTag, self.devt.major(),
                          self.devt.minor(), self.inode.perms(),
                          self.inode.owner(), self.inode.group())
        else:
            if self.lsTag == 'c':
                flags = stat.S_IFCHR
            else:
                flags = stat.S_IFBLK
            os.mknod(target, flags, os.makedev(self.devt.major(),
                                               self.devt.minor()))

            return File.restore(self, root, target, journal=journal,
                nameLookup=nameLookup, **kwargs)
        return target 
開發者ID:sassoftware,項目名稱:conary,代碼行數:25,代碼來源:files.py

示例3: makedev

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFCHR [as 別名]
def makedev(self, tarinfo, targetpath):
        """Make a character or block device called targetpath.
        """
        if not hasattr(os, "mknod") or not hasattr(os, "makedev"):
            raise ExtractError("special devices not supported by system")

        mode = tarinfo.mode
        if tarinfo.isblk():
            mode |= stat.S_IFBLK
        else:
            mode |= stat.S_IFCHR

        os.mknod(targetpath, mode,
                 os.makedev(tarinfo.devmajor, tarinfo.devminor)) 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:16,代碼來源:tarfile.py

示例4: create_tunnel

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFCHR [as 別名]
def create_tunnel(self):
        node = '/dev/net/tun'
        if not os.path.exists(node):
            os.makedirs(os.path.dirname(node), exist_ok=True)
            os.mknod(node, mode=0o640 | stat.S_IFCHR, device = os.makedev(10, 200)) 
開發者ID:dlenski,項目名稱:vpn-slice,代碼行數:7,代碼來源:linux.py

示例5: get_char

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFCHR [as 別名]
def get_char(self, major, minor):
        return self.get(S_IFCHR, self._rdev(major, minor)) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:4,代碼來源:devdb.py

示例6: makedev

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import S_IFCHR [as 別名]
def makedev(dev_path):
    for i, dev in enumerate(['stdin', 'stdout', 'stderr']):
        os.symlink('/proc/self/fd/%d' % i, os.path.join(dev_path, dev))
    os.symlink('/proc/self/fd', os.path.join(dev_path, 'fd'))
    # Add extra devices
    DEVICES = {'null': (stat.S_IFCHR, 1, 3), 'zero': (stat.S_IFCHR, 1, 5),
               'random': (stat.S_IFCHR, 1, 8), 'urandom': (stat.S_IFCHR, 1, 9),
               'console': (stat.S_IFCHR, 136, 1), 'tty': (stat.S_IFCHR, 5, 0),
               'full': (stat.S_IFCHR, 1, 7)}
    for device, (dev_type, major, minor) in DEVICES.iteritems():
        os.mknod(os.path.join(dev_path, device),
                 0o666 | dev_type, os.makedev(major, minor)) 
開發者ID:Fewbytes,項目名稱:rubber-docker,代碼行數:14,代碼來源:rd.py


注:本文中的stat.S_IFCHR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。