Changeset 5545

Show
Ignore:
Timestamp:
07/09/12 11:50:05 (7 years ago)
Author:
nitin
Message:

addition of chmod and a unit test for it.

Location:
seattle/branches/nacl_repy/seattlelib
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • seattle/branches/nacl_repy/seattlelib/lind_fs_calls.py

    r5541 r5545  
    16641664 
    16651665 
     1666 
     1667#### CHMOD #### 
     1668 
     1669 
     1670def chmod_syscall(path, mode): 
     1671  """ 
     1672    http://linux.die.net/man/2/chmod 
     1673  """ 
     1674  # in an abundance of caution, I'll grab a lock... 
     1675  filesystemmetadatalock.acquire(True) 
     1676 
     1677  # ... but always release it... 
     1678  try: 
     1679    truepath = _get_absolute_path(path) 
     1680 
     1681    # is the path there? 
     1682    if truepath not in fastinodelookuptable: 
     1683      raise SyscallError("chmod_syscall", "ENOENT", "The path does not exist.") 
     1684 
     1685    thisinode = fastinodelookuptable[truepath] 
     1686 
     1687    # be sure there aren't extra mode bits... No errno seems to exist for this 
     1688    assert(mode & S_IRWXA == mode) 
     1689 
     1690    # should overwrite any previous permissions, according to POSIX 
     1691    filesystemmetadata['inodetable'][thisinode]['mode'] = S_IFREG + mode 
     1692 
     1693  finally: 
     1694    persist_metadata(METADATAFILENAME) 
     1695    filesystemmetadatalock.release()