本文整理汇总了C++中cfPS函数的典型用法代码示例。如果您正苦于以下问题:C++ cfPS函数的具体用法?C++ cfPS怎么用?C++ cfPS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cfPS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: DeleteVirtNetwork
static int DeleteVirtNetwork(virConnectPtr vc, char **networks, Attributes a, Promise *pp)
{
virNetworkPtr network;
int ret = true;
if ((network = virNetworkLookupByName(vc, pp->promiser)) == NULL)
{
cfPS(cf_verbose, CF_NOP, "", pp, a, " -> Couldn't find a network called \"%s\" - promise assumed kept\n",
pp->promiser);
return true;
}
if (virNetworkDestroy(network) == 0)
{
cfPS(cf_inform, CF_CHG, "", pp, a, " -> Deleted network \"%s\" - promise repaired\n", pp->promiser);
}
else
{
cfPS(cf_error, CF_FAIL, "", pp, a, " !! Network deletion of \"%s\" failed\n", pp->promiser);
ret = false;
}
virNetworkFree(network);
return ret;
}
开发者ID:cyphermaster,项目名称:core,代码行数:25,代码来源:verify_environments.c
示例2: MakeHardLink
bool MakeHardLink(EvalContext *ctx, const char *from, const char *to, Attributes attr, const Promise *pp,
PromiseResult *result)
{
if (DONTDO)
{
Log(LOG_LEVEL_ERR, "Need to hard link files '%s' -> '%s'", from, to);
return false;
}
else
{
if (link(to, from) == -1)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, attr, "Couldn't hard link '%s' to '%s'. (link: %s)",
to, from, GetErrorStr());
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
return false;
}
else
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, attr, "Hard linked files '%s' -> '%s'", from, to);
*result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
return true;
}
}
}
开发者ID:maciejmrowiec,项目名称:core,代码行数:25,代码来源:files_links.c
示例3: VerifyFreeSpace
static int VerifyFreeSpace(char *file, Attributes a, Promise *pp)
{
struct stat statbuf;
long kilobytes;
#ifdef MINGW
if (!a.volume.check_foreign)
{
CfOut(cf_verbose, "", "storage.volume.check_foreign is not supported on Windows (checking every mount)");
}
#endif /* MINGW */
if (cfstat(file, &statbuf) == -1)
{
CfOut(cf_error, "stat", "Couldn't stat %s checking diskspace\n", file);
return true;
}
#ifndef MINGW
if (!a.volume.check_foreign)
{
if (IsForeignFileSystem(&statbuf, file))
{
CfOut(cf_inform, "", "Filesystem %s is mounted from a foreign system, so skipping it", file);
return true;
}
}
#endif /* NOT MINGW */
kilobytes = a.volume.freespace;
if (kilobytes < 0)
{
int free = (int) GetDiskUsage(file, cfpercent);
kilobytes = -1 * kilobytes;
if (free < (int) kilobytes)
{
cfPS(cf_error, CF_FAIL, "", pp, a,
" !! Free disk space is under %ld%% for volume containing %s (%d%% free)\n", kilobytes, file, free);
return false;
}
}
else
{
off_t free = GetDiskUsage(file, cfabs);
kilobytes = kilobytes / 1024;
if (free < kilobytes)
{
cfPS(cf_error, CF_FAIL, "", pp, a, " !! Disk space under %ld kB for volume containing %s (%lld kB free)\n",
kilobytes, file, (long long) free);
return false;
}
}
return true;
}
开发者ID:frerich,项目名称:core,代码行数:60,代码来源:verify_storage.c
示例4: DeleteVirt
static int DeleteVirt(virConnectPtr vc, char *uri, Attributes a, Promise *pp)
{
virDomainPtr dom;
int ret = true;
dom = virDomainLookupByName(vc, pp->promiser);
if (dom)
{
if (virDomainDestroy(dom) == -1)
{
cfPS(cf_verbose, CF_FAIL, "", pp, a, " !! Failed to delete virtual domain \"%s\"\n", pp->promiser);
ret = false;
}
else
{
cfPS(cf_verbose, CF_CHG, "", pp, a, " -> Deleted virtual domain \"%s\"\n", pp->promiser);
}
virDomainFree(dom);
}
else
{
cfPS(cf_verbose, CF_NOP, "", pp, a, " -> No such virtual domain called \"%s\" - promise kept\n", pp->promiser);
}
return ret;
}
开发者ID:cyphermaster,项目名称:core,代码行数:28,代码来源:verify_environments.c
示例5: DeleteVirt
static PromiseResult DeleteVirt(EvalContext *ctx, virConnectPtr vc, Attributes a, const Promise *pp)
{
virDomainPtr dom;
dom = virDomainLookupByName(vc, pp->promiser);
PromiseResult result = PROMISE_RESULT_NOOP;
if (dom)
{
if (virDomainDestroy(dom) == -1)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Failed to delete virtual domain '%s'", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
}
else
{
cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_CHANGE, pp, a, "Deleted virtual domain '%s'", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_CHANGE);
}
virDomainFree(dom);
}
else
{
cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, pp, a, "No such virtual domain called '%s' - promise kept", pp->promiser);
}
return result;
}
开发者ID:atsaloli,项目名称:core,代码行数:29,代码来源:verify_environments.c
示例6: VerifyUnmount
int VerifyUnmount(char *name, Attributes a, Promise *pp)
{
char comm[CF_BUFSIZE], line[CF_BUFSIZE];
FILE *pfp;
char *mountpt;
mountpt = name;
if (!DONTDO)
{
snprintf(comm, CF_BUFSIZE, "%s %s", VUNMOUNTCOMM[VSYSTEMHARDCLASS], mountpt);
if ((pfp = cf_popen(comm, "r")) == NULL)
{
CfOut(cf_error, "", " !! Failed to open pipe from %s\n", VUNMOUNTCOMM[VSYSTEMHARDCLASS]);
return 0;
}
CfReadLine(line, CF_BUFSIZE, pfp);
if ((strstr(line, "busy")) || (strstr(line, "Busy")))
{
cfPS(cf_inform, CF_INTERPT, "", pp, a, " !! The device under %s cannot be unmounted\n", mountpt);
cf_pclose(pfp);
return 1;
}
cf_pclose(pfp);
}
cfPS(cf_inform, CF_CHG, "", pp, a, " -> Unmounting %s to keep promise\n", mountpt);
return 0;
}
开发者ID:werkt,项目名称:cfengine-community,代码行数:33,代码来源:nfs.c
示例7: DeleteVirt
static int DeleteVirt(EvalContext *ctx, virConnectPtr vc, Attributes a, Promise *pp)
{
virDomainPtr dom;
int ret = true;
dom = virDomainLookupByName(vc, pp->promiser);
if (dom)
{
if (virDomainDestroy(dom) == -1)
{
cfPS(ctx, OUTPUT_LEVEL_VERBOSE, PROMISE_RESULT_FAIL, "", pp, a, " !! Failed to delete virtual domain \"%s\"\n", pp->promiser);
ret = false;
}
else
{
cfPS(ctx, OUTPUT_LEVEL_VERBOSE, PROMISE_RESULT_CHANGE, "", pp, a, " -> Deleted virtual domain \"%s\"\n", pp->promiser);
}
virDomainFree(dom);
}
else
{
cfPS(ctx, OUTPUT_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, "", pp, a, " -> No such virtual domain called \"%s\" - promise kept\n", pp->promiser);
}
return ret;
}
开发者ID:jooooooon,项目名称:core,代码行数:28,代码来源:verify_environments.c
示例8: DeleteVirtNetwork
static int DeleteVirtNetwork(EvalContext *ctx, virConnectPtr vc, Attributes a, Promise *pp)
{
virNetworkPtr network;
int ret = true;
if ((network = virNetworkLookupByName(vc, pp->promiser)) == NULL)
{
cfPS(ctx, OUTPUT_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, "", pp, a, " -> Couldn't find a network called \"%s\" - promise assumed kept\n",
pp->promiser);
return true;
}
if (virNetworkDestroy(network) == 0)
{
cfPS(ctx, OUTPUT_LEVEL_INFORM, PROMISE_RESULT_CHANGE, "", pp, a, " -> Deleted network \"%s\" - promise repaired\n", pp->promiser);
}
else
{
cfPS(ctx, OUTPUT_LEVEL_ERROR, PROMISE_RESULT_FAIL, "", pp, a, " !! Network deletion of \"%s\" failed\n", pp->promiser);
ret = false;
}
virNetworkFree(network);
return ret;
}
开发者ID:jooooooon,项目名称:core,代码行数:25,代码来源:verify_environments.c
示例9: VerifyMount
int VerifyMount(char *name, Attributes a, Promise *pp)
{
char comm[CF_BUFSIZE], line[CF_BUFSIZE];
FILE *pfp;
char *host, *rmountpt, *mountpt;
host = a.mount.mount_server;
rmountpt = a.mount.mount_source;
mountpt = name;
if (!DONTDO)
{
snprintf(comm, CF_BUFSIZE, "%s %s:%s %s", GetArg0(VMOUNTCOMM[VSYSTEMHARDCLASS]), host, rmountpt, mountpt);
if ((pfp = cf_popen(comm, "r")) == NULL)
{
CfOut(cf_error, "", " !! Failed to open pipe from %s\n", GetArg0(VMOUNTCOMM[VSYSTEMHARDCLASS]));
return 0;
}
CfReadLine(line, CF_BUFSIZE, pfp);
if (strstr(line, "busy") || strstr(line, "Busy"))
{
cfPS(cf_inform, CF_INTERPT, "", pp, a, " !! The device under %s cannot be mounted\n", mountpt);
cf_pclose(pfp);
return 1;
}
cf_pclose(pfp);
}
cfPS(cf_inform, CF_CHG, "", pp, a, " -> Mounting %s to keep promise\n", mountpt);
return 0;
}
开发者ID:joegen,项目名称:sipx-externals,代码行数:35,代码来源:nfs.c
示例10: DeleteVirtNetwork
static PromiseResult DeleteVirtNetwork(EvalContext *ctx, virConnectPtr vc, Attributes a, const Promise *pp)
{
virNetworkPtr network;
if ((network = virNetworkLookupByName(vc, pp->promiser)) == NULL)
{
cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, pp, a, "Couldn't find a network called '%s' - promise assumed kept",
pp->promiser);
return PROMISE_RESULT_NOOP;
}
PromiseResult result = PROMISE_RESULT_NOOP;
if (virNetworkDestroy(network) == 0)
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a, "Deleted network '%s' - promise repaired", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_CHANGE);
}
else
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Network deletion of '%s' failed", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
}
virNetworkFree(network);
return result;
}
开发者ID:atsaloli,项目名称:core,代码行数:26,代码来源:verify_environments.c
示例11: RunCmpCommand
static VersionCmpResult RunCmpCommand(const char *command, const char *v1, const char *v2, Attributes a, Promise *pp)
{
char expanded_command[CF_EXPANDSIZE];
SetNewScope("cf_pack_context");
NewScalar("cf_pack_context", "v1", v1, cf_str);
NewScalar("cf_pack_context", "v2", v2, cf_str);
ExpandScalar(command, expanded_command);
DeleteScope("cf_pack_context");
FILE *pfp = a.packages.package_commands_useshell ? cf_popen_sh(expanded_command, "w") : cf_popen(expanded_command, "w");
if (pfp == NULL)
{
cfPS(cf_error, CF_FAIL, "cf_popen", pp, a, "Can not start package version comparison command: %s", expanded_command);
return VERCMP_ERROR;
}
CfOut(cf_verbose, "", "Executing %s", expanded_command);
int retcode = cf_pclose(pfp);
if (retcode == -1)
{
cfPS(cf_error, CF_FAIL, "cf_pclose", pp, a, "Error during package version comparison command execution: %s",
expanded_command);
return VERCMP_ERROR;
}
return retcode == 0;
}
开发者ID:FraserMCampbell,项目名称:core,代码行数:31,代码来源:vercmp.c
示例12: MakeLink
static bool MakeLink(EvalContext *ctx, const char *from, const char *to, Attributes attr, const Promise *pp,
PromiseResult *result)
{
if (DONTDO || (attr.transaction.action == cfa_warn))
{
Log(LOG_LEVEL_WARNING, "Need to link files '%s' -> '%s'", from, to);
return false;
}
else
{
if (symlink(to, from) == -1)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, attr, "Couldn't link '%s' to '%s'. (symlink: %s)",
to, from, GetErrorStr());
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
return false;
}
else
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, attr, "Linked files '%s' -> '%s'", from, to);
*result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
return true;
}
}
}
开发者ID:maciejmrowiec,项目名称:core,代码行数:25,代码来源:files_links.c
示例13: CreateVirtNetwork
static PromiseResult CreateVirtNetwork(EvalContext *ctx, virConnectPtr vc, char **networks, Attributes a, const Promise *pp)
{
virNetworkPtr network;
char *xml_file;
char defaultxml[CF_MAXVARSIZE];
int i, found = false;
snprintf(defaultxml, CF_MAXVARSIZE - 1,
"<network>"
"<name>%s</name>"
"<bridge name=\"virbr0\" />"
"<forward mode=\"nat\"/>"
"<ip address=\"192.168.122.1\" netmask=\"255.255.255.0\">"
"<dhcp>"
"<range start=\"192.168.122.2\" end=\"192.168.122.254\" />" "</dhcp>" "</ip>" "</network>", pp->promiser);
for (i = 0; networks[i] != NULL; i++)
{
Log(LOG_LEVEL_VERBOSE, "Discovered a running network '%s'", networks[i]);
if (strcmp(networks[i], pp->promiser) == 0)
{
found = true;
}
}
if (found)
{
cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, pp, a, "Network '%s' exists - promise kept", pp->promiser);
return PROMISE_RESULT_NOOP;
}
if (a.env.spec)
{
xml_file = xstrdup(a.env.spec);
}
else
{
xml_file = xstrdup(defaultxml);
}
PromiseResult result = PROMISE_RESULT_NOOP;
if ((network = virNetworkCreateXML(vc, xml_file)) == NULL)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Unable to create network '%s'", pp->promiser);
free(xml_file);
return PROMISE_RESULT_FAIL;
}
else
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a, "Created network '%s' - promise repaired", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_CHANGE);
}
free(xml_file);
virNetworkFree(network);
return result;
}
开发者ID:atsaloli,项目名称:core,代码行数:59,代码来源:verify_environments.c
示例14: Unix_DoAllSignals
int Unix_DoAllSignals(Item *siglist, Attributes a, Promise *pp)
{
Item *ip;
Rlist *rp;
pid_t pid;
int killed = false;
CfDebug("DoSignals(%s)\n", pp->promiser);
if (siglist == NULL)
{
return 0;
}
if (a.signals == NULL)
{
CfOut(cf_verbose, "", " -> No signals to send for %s\n", pp->promiser);
return 0;
}
for (ip = siglist; ip != NULL; ip = ip->next)
{
pid = ip->counter;
for (rp = a.signals; rp != NULL; rp = rp->next)
{
int signal = Signal2Int(rp->item);
if (!DONTDO)
{
if (signal == SIGKILL || signal == SIGTERM)
{
killed = true;
}
if (kill((pid_t) pid, signal) < 0)
{
cfPS(cf_verbose, CF_FAIL, "kill", pp, a,
" !! Couldn't send promised signal \'%s\' (%d) to pid %jd (might be dead)\n", ScalarValue(rp),
signal, (intmax_t)pid);
}
else
{
cfPS(cf_inform, CF_CHG, "", pp, a, " -> Signalled '%s' (%d) to process %jd (%s)\n",
ScalarValue(rp), signal, (intmax_t)pid, ip->name);
}
}
else
{
CfOut(cf_error, "", " -> Need to keep signal promise \'%s\' in process entry %s",
ScalarValue(rp), ip->name);
}
}
}
return killed;
}
开发者ID:rdparker,项目名称:core,代码行数:57,代码来源:unix.c
示例15: CreateVirtNetwork
static int CreateVirtNetwork(virConnectPtr vc, char **networks, Attributes a, Promise *pp)
{
virNetworkPtr network;
char *xml_file;
char defaultxml[CF_MAXVARSIZE];
int i, found = false;
snprintf(defaultxml, CF_MAXVARSIZE - 1,
"<network>"
"<name>%s</name>"
"<bridge name=\"virbr0\" />"
"<forward mode=\"nat\"/>"
"<ip address=\"192.168.122.1\" netmask=\"255.255.255.0\">"
"<dhcp>"
"<range start=\"192.168.122.2\" end=\"192.168.122.254\" />" "</dhcp>" "</ip>" "</network>", pp->promiser);
for (i = 0; networks[i] != NULL; i++)
{
CfOut(cf_verbose, "", " -> Discovered a running network \"%s\"", networks[i]);
if (strcmp(networks[i], pp->promiser) == 0)
{
found = true;
}
}
if (found)
{
cfPS(cf_verbose, CF_NOP, "", pp, a, " -> Network \"%s\" exists - promise kept\n", pp->promiser);
return true;
}
if (a.env.spec)
{
xml_file = xstrdup(a.env.spec);
}
else
{
xml_file = xstrdup(defaultxml);
}
if ((network = virNetworkCreateXML(vc, xml_file)) == NULL)
{
cfPS(cf_error, CF_FAIL, "", pp, a, " !! Unable to create network \"%s\"\n", pp->promiser);
free(xml_file);
return false;
}
else
{
cfPS(cf_inform, CF_CHG, "", pp, a, " -> Created network \"%s\" - promise repaired\n", pp->promiser);
}
free(xml_file);
virNetworkFree(network);
return true;
}
开发者ID:cyphermaster,项目名称:core,代码行数:57,代码来源:verify_environments.c
示例16: DoAllSignals
int DoAllSignals(EvalContext *ctx, Item *siglist, Attributes a, const Promise *pp, PromiseResult *result)
{
Item *ip;
Rlist *rp;
pid_t pid;
int killed = false;
if (siglist == NULL)
{
return 0;
}
if (a.signals == NULL)
{
Log(LOG_LEVEL_VERBOSE, "No signals to send for '%s'", pp->promiser);
return 0;
}
for (ip = siglist; ip != NULL; ip = ip->next)
{
pid = ip->counter;
for (rp = a.signals; rp != NULL; rp = rp->next)
{
int signal = SignalFromString(RlistScalarValue(rp));
if (!DONTDO)
{
if ((signal == SIGKILL) || (signal == SIGTERM))
{
killed = true;
}
if (kill((pid_t) pid, signal) < 0)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a,
"Couldn't send promised signal '%s' (%d) to pid %jd (might be dead). (kill: %s)", RlistScalarValue(rp),
signal, (intmax_t)pid, GetErrorStr());
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
}
else
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a, "Signalled '%s' (%d) to process %jd (%s)",
RlistScalarValue(rp), signal, (intmax_t)pid, ip->name);
*result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
}
}
else
{
Log(LOG_LEVEL_ERR, "Need to keep signal promise '%s' in process entry '%s'",
RlistScalarValue(rp), ip->name);
}
}
}
return killed;
}
开发者ID:awsiv,项目名称:core,代码行数:57,代码来源:verify_processes.c
示例17: DoAllSignals
static int DoAllSignals(Item *siglist, Attributes a, Promise *pp)
{
Item *ip;
Rlist *rp;
pid_t pid;
int killed = false;
CfDebug("DoSignals(%s)\n", pp->promiser);
if (siglist == NULL)
{
return 0;
}
if (a.signals == NULL)
{
CfOut(OUTPUT_LEVEL_VERBOSE, "", " -> No signals to send for %s\n", pp->promiser);
return 0;
}
for (ip = siglist; ip != NULL; ip = ip->next)
{
pid = ip->counter;
for (rp = a.signals; rp != NULL; rp = rp->next)
{
int signal = SignalFromString(rp->item);
if (!DONTDO)
{
if ((signal == SIGKILL) || (signal == SIGTERM))
{
killed = true;
}
if (kill((pid_t) pid, signal) < 0)
{
cfPS(OUTPUT_LEVEL_VERBOSE, CF_FAIL, "kill", pp, a,
" !! Couldn't send promised signal \'%s\' (%d) to pid %jd (might be dead)\n", RlistScalarValue(rp),
signal, (intmax_t)pid);
}
else
{
cfPS(OUTPUT_LEVEL_INFORM, CF_CHG, "", pp, a, " -> Signalled '%s' (%d) to process %jd (%s)\n",
RlistScalarValue(rp), signal, (intmax_t)pid, ip->name);
}
}
else
{
CfOut(OUTPUT_LEVEL_ERROR, "", " -> Need to keep signal promise \'%s\' in process entry %s",
RlistScalarValue(rp), ip->name);
}
}
}
return killed;
}
开发者ID:FancsalMelinda,项目名称:core,代码行数:57,代码来源:verify_processes.c
示例18: VerifyFreeSpace
static PromiseResult VerifyFreeSpace(EvalContext *ctx, char *file, Attributes a, Promise *pp)
{
struct stat statbuf;
#ifdef __MINGW32__
if (!a.volume.check_foreign)
{
Log(LOG_LEVEL_VERBOSE, "storage.volume.check_foreign is not supported on Windows (checking every mount)");
}
#endif /* __MINGW32__ */
if (stat(file, &statbuf) == -1)
{
Log(LOG_LEVEL_ERR, "Couldn't stat '%s' while checking diskspace. (stat: %s)", file, GetErrorStr());
return PROMISE_RESULT_NOOP;
}
#ifndef __MINGW32__
if (!a.volume.check_foreign)
{
if (IsForeignFileSystem(&statbuf, file))
{
Log(LOG_LEVEL_INFO, "Filesystem '%s' is mounted from a foreign system, so skipping it", file);
return PROMISE_RESULT_NOOP;
}
}
#endif /* !__MINGW32__ */
if (a.volume.freespace < 0)
{
int threshold_percentage = -a.volume.freespace;
int free_percentage = GetDiskUsage(file, cfpercent);
if (free_percentage < threshold_percentage)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a,
"Free disk space is under %d%% for volume containing '%s', %d%% free",
threshold_percentage, file, free_percentage);
return PROMISE_RESULT_FAIL;
}
}
else
{
off_t threshold = a.volume.freespace;
off_t free_bytes = GetDiskUsage(file, cfabs);
if (free_bytes < threshold)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Disk space under %jd kB for volume containing '%s' (%jd kB free)",
(intmax_t) (threshold / 1024), file, (intmax_t) (free_bytes / 1024));
return PROMISE_RESULT_FAIL;
}
}
return PROMISE_RESULT_NOOP;
}
开发者ID:cduclos,项目名称:core,代码行数:56,代码来源:verify_storage.c
示例19: VerifyFreeSpace
static int VerifyFreeSpace(EvalContext *ctx, char *file, Attributes a, Promise *pp)
{
struct stat statbuf;
#ifdef __MINGW32__
if (!a.volume.check_foreign)
{
CfOut(OUTPUT_LEVEL_VERBOSE, "", "storage.volume.check_foreign is not supported on Windows (checking every mount)");
}
#endif /* __MINGW32__ */
if (cfstat(file, &statbuf) == -1)
{
CfOut(OUTPUT_LEVEL_ERROR, "stat", "Couldn't stat %s checking diskspace\n", file);
return true;
}
#ifndef __MINGW32__
if (!a.volume.check_foreign)
{
if (IsForeignFileSystem(&statbuf, file))
{
CfOut(OUTPUT_LEVEL_INFORM, "", "Filesystem %s is mounted from a foreign system, so skipping it", file);
return true;
}
}
#endif /* !__MINGW32__ */
if (a.volume.freespace < 0)
{
int threshold_percentage = -a.volume.freespace;
int free_percentage = GetDiskUsage(file, cfpercent);
if (free_percentage < threshold_percentage)
{
cfPS(ctx, OUTPUT_LEVEL_ERROR, PROMISE_RESULT_FAIL, "", pp, a,
" !! Free disk space is under %d%% for volume containing %s (%d%% free)\n",
threshold_percentage, file, free_percentage);
return false;
}
}
else
{
off_t threshold = a.volume.freespace;
off_t free_bytes = GetDiskUsage(file, cfabs);
if (free_bytes < threshold)
{
cfPS(ctx, OUTPUT_LEVEL_ERROR, PROMISE_RESULT_FAIL, "", pp, a, " !! Disk space under %jd kB for volume containing %s (%jd kB free)\n",
(intmax_t) (threshold / 1024), file, (intmax_t) (free_bytes / 1024));
return false;
}
}
return true;
}
开发者ID:rpoyner,项目名称:core,代码行数:56,代码来源:verify_storage.c
示例20: VerifyMount
int VerifyMount(EvalContext *ctx, char *name, Attributes a, Promise *pp)
{
char comm[CF_BUFSIZE], line[CF_BUFSIZE];
FILE *pfp;
char *host, *rmountpt, *mountpt, *opts=NULL;
host = a.mount.mount_server;
rmountpt = a.mount.mount_source;
mountpt = name;
/* Check for options required for this mount - i.e., -o ro,rsize, etc. */
if (a.mount.mount_options)
{
opts = Rlist2String(a.mount.mount_options, ",");
}
else
{
opts = xstrdup(VMOUNTOPTS[VSYSTEMHARDCLASS]);
}
if (!DONTDO)
{
snprintf(comm, CF_BUFSIZE, "%s -o %s %s:%s %s", CommandArg0(VMOUNTCOMM[VSYSTEMHARDCLASS]), opts, host, rmountpt, mountpt);
if ((pfp = cf_popen(comm, "r", true)) == NULL)
{
Log(LOG_LEVEL_ERR, "Failed to open pipe from %s", CommandArg0(VMOUNTCOMM[VSYSTEMHARDCLASS]));
return 0;
}
ssize_t res = CfReadLine(line, CF_BUFSIZE, pfp);
if (res == -1)
{
Log(LOG_LEVEL_ERR, "Unable to read output of mount command. (fread: %s)", GetErrorStr());
cf_pclose(pfp);
return 0;
}
if (res != 0 && ((strstr(line, "busy")) || (strstr(line, "Busy"))))
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_INTERRUPTED, pp, a, "The device under %s cannot be mounted\n", mountpt);
cf_pclose(pfp);
return 1;
}
cf_pclose(pfp);
}
/* Since opts is either Rlist2String or xstrdup'd, we need to always free it */
free(opts);
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a, "Mounting %s to keep promise\n", mountpt);
return 0;
}
开发者ID:ouafae31,项目名称:core,代码行数:55,代码来源:nfs.c
注:本文中的cfPS函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论