Exemplo n.º 1
0
 def fgetattr(self):
     log("fstat", self.fd)
     try:
         stats = lind.fstat_syscall(self.fd)
     except lind.SyscallError, e:
         return -errno[e[1]]
Exemplo n.º 2
0
import lind_test_server
from lind_fs_constants import *

# this is very similar to the stat complex test, I had to remove the links
# though

# Let's add a few files, etc. to the system and see if it works...
lind_test_server.load_fs()

myfd = lind_test_server.open_syscall('/foo',O_CREAT | O_WRONLY,S_IRWXA)

# write should succeed
assert(lind_test_server.write_syscall(myfd,'hi') == 2)

stat_result = lind_test_server.fstat_syscall(myfd)

# ensure the file has size 2
assert(stat_result[7] == 2)

# ensure the link count is 1
assert(stat_result[3] == 1)

Exemplo n.º 3
0
File: ut_lind_fs_mknod.py

Unit test for mknod_syscall(), which is used to create special files.
"""

import lind_test_server
from lind_fs_constants import *

lind_test_server._blank_fs_init()
lind_test_server._load_lower_handle_stubs()

# let's create /dev/null...
lind_test_server.mknod_syscall('/null', S_IFCHR, (1, 3))
fd = lind_test_server.open_syscall('/null', O_CREAT | O_RDWR, S_IRWXA)

assert lind_test_server.fstat_syscall(fd)[2] & S_FILETYPEFLAGS == S_IFCHR,\
  "File should be a Character file."
assert lind_test_server.fstat_syscall(fd)[6] == (1, 3),\
  "File is not /dev/null."
assert lind_test_server.write_syscall(fd, "test") == 4,\
  "Write failed to /dev/null file."
assert lind_test_server.read_syscall(fd, 10) == '',\
  "Read failed from /dev/null file."

lind_test_server.close_syscall(fd)


# let's create /dev/random...
lind_test_server.mknod_syscall('/random', S_IFCHR, (1, 8))
fd = lind_test_server.open_syscall('/random', O_CREAT | O_RDWR, S_IRWXA)
Exemplo n.º 4
0
      _mirror_stat_data(os.path.join(rootpath,currentdir),currentdir)


  # Okay, I have made the path now.   Only one thing remains, adding the file
  posixfo = open(posixfn)
  filecontents = posixfo.read()
  posixfo.close()

  # make the new file, truncating any existing contents...
  lindfd = lind_test_server.open_syscall(normalizedlindfn, O_CREAT|O_EXCL|O_TRUNC|O_WRONLY, S_IRWXA)

  # should write all at once...
  datalen = lind_test_server.write_syscall(lindfd, filecontents)
  assert(datalen == len(filecontents))
  
  inode = lind_test_server.fstat_syscall(lindfd)[1]

  lind_test_server.close_syscall(lindfd)
  
  
  print "Copied "+posixfn+" as "+fullfilename+"("+str(inode)+")"

   # fix stat, etc.
  _mirror_stat_data(posixfn,normalizedlindfn)


def deltree_lind(dirname):
  # took part of the code from _find_all_paths_recursively method below.
  # It recursively looks at all child dirs

  # I need to open the dir to use getdents...
Exemplo n.º 5
0
import lind_test_server
from lind_fs_constants import *

# this is very similar to the stat complex test, I had to remove the links
# though

# Let's add a few files, etc. to the system and see if it works...
lind_test_server.load_fs()

myfd = lind_test_server.open_syscall('/foo', O_CREAT | O_WRONLY, S_IRWXA)

# write should succeed
assert (lind_test_server.write_syscall(myfd, 'hi') == 2)

stat_result = lind_test_server.fstat_syscall(myfd)

# ensure the file has size 2
assert (stat_result[7] == 2)

# ensure the link count is 1
assert (stat_result[3] == 1)
Exemplo n.º 6
0
 def fgetattr(self):
     log("fstat", self.fd)
     try:
         stats = lind.fstat_syscall(self.fd)
     except lind.SyscallError, e:
         return -errno[e[1]]