You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
382 B

  1. #!/usr/bin/env python3
  2. import os
  3. import sys
  4. import tempfile
  5. import mmap
  6. import resource
  7. (fd,filepath) = tempfile.mkstemp(dir=sys.argv[1])
  8. os.close(fd)
  9. fd = os.open(filepath,os.O_RDWR|os.O_DIRECT|os.O_TRUNC)
  10. os.unlink(filepath)
  11. data = mmap.mmap(-1, resource.getpagesize())
  12. os.write(fd,data)
  13. os.lseek(fd,0,os.SEEK_SET)
  14. data = os.read(fd,resource.getpagesize())
  15. os.close(fd)