From: markus schnalke Date: Thu, 9 Feb 2012 20:12:58 +0000 (+0100) Subject: Fixed dist(1): The link() must fail, because m_mktemp2() creates the file. X-Git-Tag: mmh-thesis-end~329 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=4150402bbbee49b71286c9d278b5e7e9a5401bc2;p=mmh Fixed dist(1): The link() must fail, because m_mktemp2() creates the file. I've decided to take the easy way: simply copy. --- diff --git a/uip/send.c b/uip/send.c index 1529c0f..a90c6b2 100644 --- a/uip/send.c +++ b/uip/send.c @@ -252,27 +252,17 @@ main(int argc, char **argv) if ((cp = getenv("mhdist")) && *cp && (distsw = atoi(cp)) && altmsg) { vec[vecp++] = "-dist"; - distfile = getcpy(m_mktemp2(altmsg, invo_name, NULL, NULL)); - if (link(altmsg, distfile) == NOTOK) { - if (errno != EXDEV) { - adios(distfile, "unable to link %s to", - altmsg); - } - free(distfile); - distfile = getcpy(m_mktemp2(NULL, invo_name, - NULL, NULL)); - if ((in = open(altmsg, O_RDONLY)) == NOTOK) { - adios(altmsg, "unable to open"); - } - fstat(in, &st2); - if ((out = creat(distfile, (int)st2.st_mode & 0777)) == - NOTOK) { - adios(distfile, "unable to write"); - } - cpydata(in, out, altmsg, distfile); - close(in); - close(out); + if ((in = open(altmsg, O_RDONLY)) == NOTOK) { + adios(altmsg, "unable to open for reading"); } + fstat(in, &st2); + distfile = getcpy(m_mktemp2(NULL, invo_name, NULL, NULL)); + if ((out = creat(distfile, (int)st2.st_mode & 0777))==NOTOK) { + adios(distfile, "unable to open for writing"); + } + cpydata(in, out, altmsg, distfile); + close(in); + close(out); } else { distfile = NULL; }