diff options
author | Thiago da Silva <thiago@redhat.com> | 2014-03-25 10:03:05 -0400 |
---|---|---|
committer | Luis Pabon <lpabon@redhat.com> | 2014-04-10 12:50:38 -0700 |
commit | 404fcd815c4abe00742531bf19a5224c0fe45b36 (patch) | |
tree | d98c09bdb14f681e7aeba7ff6bec594899526901 /gluster/swift/common/fs_utils.py | |
parent | b00a99673233b8fe0a93c6f9095b435cb2569330 (diff) |
Updating code to call fs_utils instead of python's os module
This change is being done to prepare the code to always call
fs_utils for all filesystem calls on the data being stored.
By creating this interface (i.e., fs_utils), we can then
make a seamless change to use the current method of 'os.'
calls over FUSE _or_ libgfapi. This new method will be introduced
in a new separate patch.
Change-Id: Ic768fa7352d7672b1f060230bb4486f0ec228152
Signed-off-by: Thiago da Silva <thiago@redhat.com>
Reviewed-on: http://review.gluster.org/7333
Reviewed-by: Prashanth Pai <ppai@redhat.com>
Reviewed-by: Luis Pabon <lpabon@redhat.com>
Tested-by: Luis Pabon <lpabon@redhat.com>
Diffstat (limited to 'gluster/swift/common/fs_utils.py')
-rw-r--r-- | gluster/swift/common/fs_utils.py | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/gluster/swift/common/fs_utils.py b/gluster/swift/common/fs_utils.py index a93fa6b..9f698df 100644 --- a/gluster/swift/common/fs_utils.py +++ b/gluster/swift/common/fs_utils.py @@ -19,10 +19,10 @@ import errno import stat import random import time +import xattr from collections import defaultdict from itertools import repeat import ctypes -import os.path as _os_path from eventlet import sleep from swift.common.utils import load_libc_function from gluster.swift.common.exceptions import FileOrDirNotFoundError, \ @@ -30,7 +30,41 @@ from gluster.swift.common.exceptions import FileOrDirNotFoundError, \ from swift.common.exceptions import DiskFileNoSpace -os_path = _os_path +def do_exists(path): + return os.path.exists(path) + + +def do_touch(path): + with open(path, 'a'): + os.utime(path, None) + + +def do_getctime(path): + return os.path.getctime(path) + + +def do_getmtime(path): + return os.path.getmtime(path) + + +def do_isdir(path): + return os.path.isdir(path) + + +def do_getsize(path): + return os.path.getsize(path) + + +def do_getxattr(path, key): + return xattr.getxattr(path, key) + + +def do_setxattr(path, key, value): + xattr.setxattr(path, key, value) + + +def do_removexattr(path, key): + xattr.removexattr(path, key) def do_walk(*args, **kwargs): @@ -212,6 +246,10 @@ def do_open(path, flags, **kwargs): return fd +def do_dup(fd): + return os.dup(fd) + + def do_close(fd): try: os.close(fd) |