'Query filesystem for maximum filename length (e.g. AUFS has 242).'

def _storage_max_filename_length(self, storage):

    dir_to_test = storage.location
    while (not os.path.exists(dir_to_test)):
        dir_to_test = os.path.dirname(dir_to_test)
    try:
        return os.pathconf(dir_to_test, 'PC_NAME_MAX')
    except Exception:
        return 255
