2021-01-22 09:36:21 +00:00
|
|
|
/*
|
|
|
|
* storage_source.h: file utility functions for FS storage backend
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007-2009, 2012-2016 Red Hat, Inc.
|
|
|
|
* Copyright (C) 2007-2008 Daniel P. Berrange
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-01-21 14:44:53 +00:00
|
|
|
#include "storage_source_conf.h"
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
#ifndef DEV_BSIZE
|
|
|
|
# define DEV_BSIZE 512
|
|
|
|
#endif
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *
|
2021-01-21 15:46:14 +00:00
|
|
|
virStorageSourceGetMetadataFromFD(const char *path,
|
|
|
|
int fd,
|
|
|
|
int format);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *
|
2021-01-21 15:46:14 +00:00
|
|
|
virStorageSourceGetMetadataFromBuf(const char *path,
|
|
|
|
char *buf,
|
|
|
|
size_t len,
|
|
|
|
int format)
|
2021-01-22 09:36:21 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *
|
|
|
|
virStorageSourceChainLookup(virStorageSource *chain,
|
|
|
|
virStorageSource *startFrom,
|
2021-01-21 15:46:14 +00:00
|
|
|
const char *name,
|
2021-01-25 14:02:26 +00:00
|
|
|
const char *diskTarget,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource **parent)
|
2021-01-22 09:36:21 +00:00
|
|
|
ATTRIBUTE_NONNULL(1);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceUpdatePhysicalSize(virStorageSource *src,
|
2021-01-22 09:36:21 +00:00
|
|
|
int fd,
|
|
|
|
struct stat const *sb);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceUpdateBackingSizes(virStorageSource *src,
|
2021-01-22 09:36:21 +00:00
|
|
|
int fd,
|
|
|
|
struct stat const *sb);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceUpdateCapacity(virStorageSource *src,
|
2021-01-22 09:36:21 +00:00
|
|
|
char *buf,
|
|
|
|
ssize_t len);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceNewFromBacking(virStorageSource *parent,
|
|
|
|
virStorageSource **backing);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
virStorageSourceParseRBDColonString(const char *rbdstr,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *src)
|
2021-01-22 09:36:21 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceGetRelativeBackingPath(virStorageSource *top,
|
|
|
|
virStorageSource *base,
|
2021-01-21 15:46:14 +00:00
|
|
|
char **relpath)
|
2021-01-22 09:36:21 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
|
|
|
|
|
|
|
int
|
|
|
|
virStorageSourceNewFromBackingAbsolute(const char *path,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource **src);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceInit(virStorageSource *src);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceInitAs(virStorageSource *src,
|
2021-01-21 15:46:14 +00:00
|
|
|
uid_t uid, gid_t gid);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceDeinit(virStorageSource *src);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceCreate(virStorageSource *src);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceUnlink(virStorageSource *src);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceStat(virStorageSource *src,
|
2021-01-21 15:46:14 +00:00
|
|
|
struct stat *st);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
ssize_t
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceRead(virStorageSource *src,
|
2021-01-21 15:46:14 +00:00
|
|
|
size_t offset,
|
|
|
|
size_t len,
|
|
|
|
char **buf);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceAccess(virStorageSource *src,
|
2021-01-21 15:46:14 +00:00
|
|
|
int mode);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-01-21 15:46:14 +00:00
|
|
|
virStorageSourceChown(const virStorageSource *src,
|
|
|
|
uid_t uid,
|
|
|
|
gid_t gid);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-01-21 15:46:14 +00:00
|
|
|
virStorageSourceSupportsSecurityDriver(const virStorageSource *src);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-01-21 15:46:14 +00:00
|
|
|
virStorageSourceSupportsAccess(const virStorageSource *src);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-01-21 15:46:14 +00:00
|
|
|
virStorageSourceSupportsCreate(const virStorageSource *src);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-01-21 15:46:14 +00:00
|
|
|
virStorageSourceSupportsBackingChainTraversal(const virStorageSource *src);
|
2021-01-22 09:36:21 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceGetMetadata(virStorageSource *src,
|
2021-01-21 15:46:14 +00:00
|
|
|
uid_t uid, gid_t gid,
|
2021-03-22 16:21:12 +00:00
|
|
|
size_t max_depth,
|
2021-01-21 15:46:14 +00:00
|
|
|
bool report_broken)
|
2021-01-22 09:36:21 +00:00
|
|
|
ATTRIBUTE_NONNULL(1);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSourceFetchRelativeBackingPath(virStorageSource *src,
|
2021-01-22 14:08:23 +00:00
|
|
|
char **relPath)
|
2021-01-22 09:36:21 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
|
|
|
|
|
void
|
2021-01-21 15:46:14 +00:00
|
|
|
virStorageSourceReportBrokenChain(int errcode,
|
2021-03-11 07:16:13 +00:00
|
|
|
virStorageSource *src,
|
|
|
|
virStorageSource *parent);
|