Revision cdeefd9b

b/lib/bdev.py
1915 1915
    if not isinstance(unique_id, (tuple, list)) or len(unique_id) != 2:
1916 1916
      raise ValueError("Invalid configuration data %s" % str(unique_id))
1917 1917
    dev_path = unique_id[1]
1918
    if os.path.exists(dev_path):
1919
      _ThrowError("File already existing: %s", dev_path)
1920 1918
    try:
1921
      f = open(dev_path, 'w')
1919
      fd = os.open(dev_path, os.O_RDWR | os.O_CREAT | os.O_EXCL)
1920
      f = os.fdopen(fd, "w")
1922 1921
      f.truncate(size * 1024 * 1024)
1923 1922
      f.close()
1924
    except IOError, err:
1923
    except EnvironmentError, err:
1924
      if err.errno == errno.EEXIST:
1925
        _ThrowError("File already existing: %s", dev_path)
1925 1926
      _ThrowError("Error in file creation: %", str(err))
1926 1927

  
1927 1928
    return FileStorage(unique_id, children, size)

Also available in: Unified diff