util: adjust indentation in previous patch

Separating the indentation from the real patch made review easier.

* src/util/util.c (virFileOpenAs): Whitespace changes.
This commit is contained in:
Eric Blake 2011-03-03 17:02:22 -07:00
parent 1fdd50f999
commit fa3e1e35eb

View File

@ -1439,8 +1439,7 @@ static int virDirCreateNoFork(const char *path, mode_t mode, uid_t uid, gid_t gi
struct stat st; struct stat st;
if ((mkdir(path, mode) < 0) if ((mkdir(path, mode) < 0)
&& !((errno == EEXIST) && (flags & VIR_DIR_CREATE_ALLOW_EXIST))) && !((errno == EEXIST) && (flags & VIR_DIR_CREATE_ALLOW_EXIST))) {
{
ret = -errno; ret = -errno;
virReportSystemError(errno, _("failed to create directory '%s'"), virReportSystemError(errno, _("failed to create directory '%s'"),
path); path);
@ -1516,28 +1515,26 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,
* following dance avoids problems caused by root-squashing * following dance avoids problems caused by root-squashing
* NFS servers. */ * NFS servers. */
{ if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) < 0) {
if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) < 0) { ret = -errno;
ret = -errno; virReportSystemError(errno,
virReportSystemError(errno, _("failed to create socket needed for '%s'"),
_("failed to create socket needed for '%s'"), path);
path); return ret;
return ret;
}
memset(&msg, 0, sizeof(msg));
iov.iov_base = &dummy;
iov.iov_len = 1;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = buf;
msg.msg_controllen = sizeof(buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
} }
memset(&msg, 0, sizeof(msg));
iov.iov_base = &dummy;
iov.iov_len = 1;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = buf;
msg.msg_controllen = sizeof(buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
forkRet = virFork(&pid); forkRet = virFork(&pid);
if (pid < 0) { if (pid < 0) {
@ -1546,29 +1543,27 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,
} }
if (pid) { /* parent */ if (pid) { /* parent */
{ VIR_FORCE_CLOSE(pair[1]);
VIR_FORCE_CLOSE(pair[1]);
do { do {
ret = recvmsg(pair[0], &msg, 0); ret = recvmsg(pair[0], &msg, 0);
} while (ret < 0 && errno == EINTR); } while (ret < 0 && errno == EINTR);
if (ret < 0) { if (ret < 0) {
ret = -errno; ret = -errno;
VIR_FORCE_CLOSE(pair[0]);
while ((waitret = waitpid(pid, NULL, 0) == -1)
&& (errno == EINTR));
goto parenterror;
}
VIR_FORCE_CLOSE(pair[0]); VIR_FORCE_CLOSE(pair[0]);
while ((waitret = waitpid(pid, NULL, 0) == -1)
&& (errno == EINTR));
goto parenterror;
}
VIR_FORCE_CLOSE(pair[0]);
/* See if fd was transferred. */ /* See if fd was transferred. */
cmsg = CMSG_FIRSTHDR(&msg); cmsg = CMSG_FIRSTHDR(&msg);
if (cmsg && cmsg->cmsg_len == CMSG_LEN(sizeof(fd)) && if (cmsg && cmsg->cmsg_len == CMSG_LEN(sizeof(fd)) &&
cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_level == SOL_SOCKET &&
cmsg->cmsg_type == SCM_RIGHTS) { cmsg->cmsg_type == SCM_RIGHTS) {
memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd)); memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));
}
} }
/* wait for child to complete, and retrieve its exit code */ /* wait for child to complete, and retrieve its exit code */
@ -1649,17 +1644,15 @@ parenterror:
path, mode); path, mode);
goto childerror; goto childerror;
} }
{ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
do { do {
ret = sendmsg(pair[1], &msg, 0); ret = sendmsg(pair[1], &msg, 0);
} while (ret < 0 && errno == EINTR); } while (ret < 0 && errno == EINTR);
if (ret < 0) { if (ret < 0) {
ret = -errno; ret = -errno;
goto childerror; goto childerror;
}
} }
ret = 0; ret = 0;