Skip to content

Commit

Permalink
Create Mach-o files with mode 0777 to allow executing them.
Browse files Browse the repository at this point in the history
Until now, I was always doing chmod +x before running my files on the
Mac.  Now files get created +x.  There's no change when overwriting
an existing file.  I needed to gmake clean my build to remove the
example programs without +x, so cvmach can create them with +x.
  • Loading branch information
kernigh committed Dec 3, 2016
1 parent 355cc06 commit 969e98b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plat/osx/cvmach/cvmach.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* libobject is pinched from the Xenix i386 cv (mach/i386/cv/cv.c).
*/

#include <fcntl.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -470,7 +471,7 @@ int
main(int argc, char *argv[])
{
uint32_t end, pad[3], sz, sz_load_cmds;
int cpu_subtype, mflag = 0;
int cpu_subtype, fd, mflag = 0;

/* General housecleaning and setup. */
output = stdout;
Expand Down Expand Up @@ -520,7 +521,11 @@ main(int argc, char *argv[])
break;

case 3: /* Both input and output files specified. */
output = fopen(argv[2], "w");
/* Use mode 0777 to allow executing the output file. */
fd = open(argv[2], O_CREAT | O_TRUNC | O_WRONLY, 0777);
if (fd < 0)
fatal("unable to open output file.");
output = fdopen(fd, "w");
if (!output)
fatal("unable to open output file.");
outputfile = argv[2];
Expand Down

0 comments on commit 969e98b

Please sign in to comment.