Reconfigure GitHub Actions

This commit is contained in:
Justine Tunney 2023-07-10 12:17:18 -07:00
parent a2d269dc38
commit a1b1fdd1a4
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
4 changed files with 31 additions and 44 deletions

View file

@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
mode: ["", tiny, rel, aarch64, tinylinux, optlinux] mode: ["", tiny, rel, tinylinux, optlinux]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3

View file

@ -78,7 +78,6 @@
"-Wa,-W", "-Wa,-W",
"-Wa,-I.", "-Wa,-I.",
"-Wa,--noexecstack", "-Wa,--noexecstack",
"-Wa,--nocompress-debug-sections",
"-Og", "-Og",
"-g", "-g",
"-gdescribe-dies", "-gdescribe-dies",

View file

@ -232,8 +232,7 @@ DEFAULT_CXXFLAGS = \
DEFAULT_ASFLAGS = \ DEFAULT_ASFLAGS = \
-W \ -W \
-I. \ -I. \
--noexecstack \ --noexecstack
--nocompress-debug-sections
DEFAULT_LDFLAGS = \ DEFAULT_LDFLAGS = \
-static \ -static \

View file

@ -17,10 +17,7 @@
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h" #include "libc/fmt/conv.h"
#include "libc/fmt/magnumstrs.internal.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/limits.h" #include "libc/limits.h"
#include "libc/runtime/runtime.h" #include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
@ -28,17 +25,16 @@
#include "libc/sysv/consts/o.h" #include "libc/sysv/consts/o.h"
char buf[65536]; char buf[65536];
const char *prog;
wontreturn void SysFail(const char *func, const char *file) { static wontreturn void Die(const char *reason) {
int e = errno; tinyprint(2, prog, ": ", reason, "\n", NULL);
fputs("dd: ", stderr); exit(1);
fputs(func, stderr); }
fputs(" failed: ", stderr);
fputs(file, stderr); static wontreturn void DieSys(const char *thing) {
fputs(": ", stderr); perror(thing);
fputs(nulltoempty(_strerdoc(e)), stderr); exit(1);
fputs("\n", stderr);
exit(__COUNTER__ + 1);
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
@ -51,6 +47,9 @@ int main(int argc, char *argv[]) {
const char *infile = "/dev/stdin"; const char *infile = "/dev/stdin";
const char *oufile = "/dev/stdout"; const char *oufile = "/dev/stdout";
prog = argv[0];
if (!prog) prog = "dd";
for (i = 1; i < argc; ++i) { for (i = 1; i < argc; ++i) {
if (argv[i][0] == 'b' && // if (argv[i][0] == 'b' && //
@ -58,8 +57,7 @@ int main(int argc, char *argv[]) {
argv[i][2] == '=') { argv[i][2] == '=') {
blocksize = strtol(argv[i] + 3 + (argv[i][3] == '"'), 0, 10); blocksize = strtol(argv[i] + 3 + (argv[i][3] == '"'), 0, 10);
if (!(0 < blocksize && blocksize <= sizeof(buf))) { if (!(0 < blocksize && blocksize <= sizeof(buf))) {
fputs("dd: bad block size\n", stderr); Die("bad block size");
return __COUNTER__ + 1;
} }
} else if (argv[i][0] == 'i' && // } else if (argv[i][0] == 'i' && //
@ -83,8 +81,7 @@ int main(int argc, char *argv[]) {
argv[i][4] == '=') { argv[i][4] == '=') {
count = strtol(argv[i] + 5 + (argv[i][5] == '"'), 0, 10); count = strtol(argv[i] + 5 + (argv[i][5] == '"'), 0, 10);
if (!(skip < 0)) { if (!(skip < 0)) {
fputs("dd: bad skip\n", stderr); Die("bad skip");
return __COUNTER__ + 1;
} }
} else if (argv[i][0] == 'c' && // } else if (argv[i][0] == 'c' && //
@ -95,18 +92,14 @@ int main(int argc, char *argv[]) {
argv[i][5] == '=') { argv[i][5] == '=') {
count = strtol(argv[i] + 6 + (argv[i][6] == '"'), 0, 10); count = strtol(argv[i] + 6 + (argv[i][6] == '"'), 0, 10);
if (!(count < 0)) { if (!(count < 0)) {
fputs("dd: bad count\n", stderr); Die("bad count");
return __COUNTER__ + 1;
} }
} else if (!strcmp(argv[i], "conv=notrunc")) { } else if (!strcmp(argv[i], "conv=notrunc")) {
oflags &= ~O_TRUNC; oflags &= ~O_TRUNC;
} else { } else {
fputs("dd: unrecognized arg: ", stderr); Die("unrecognized arg");
fputs(argv[i], stderr);
fputs("\n", stderr);
return __COUNTER__ + 1;
} }
} }
@ -114,16 +107,16 @@ int main(int argc, char *argv[]) {
int fdin, fdout; int fdin, fdout;
if ((fdin = open(infile, O_RDONLY)) == -1) { if ((fdin = open(infile, O_RDONLY)) == -1) {
SysFail("open", infile); DieSys(infile);
} }
if ((fdout = open(oufile, oflags, 0644)) == -1) { if ((fdout = open(oufile, oflags, 0644)) == -1) {
SysFail("open", oufile); DieSys(oufile);
} }
if (skip) { if (skip) {
if (lseek(fdin, skip, SEEK_SET) == -1) { if (lseek(fdin, skip, SEEK_SET) == -1) {
SysFail("lseek", infile); DieSys(infile);
} }
} }
@ -131,31 +124,27 @@ int main(int argc, char *argv[]) {
rc = read(fdin, buf, blocksize); rc = read(fdin, buf, blocksize);
if (rc == -1) { if (rc == -1) {
SysFail("read", infile); DieSys(infile);
} }
if (rc != blocksize) { if (rc != blocksize) {
int e = errno; Die("failed to read full blocksize");
fputs("dd: failed to read blocksize: ", stderr);
fputs(infile, stderr);
fputs("\n", stderr);
return __COUNTER__ + 1;
} }
rc = write(fdout, buf, blocksize); rc = write(fdout, buf, blocksize);
if (rc == -1) { if (rc == -1) {
SysFail("write", oufile); DieSys(oufile);
} }
if (rc != blocksize) { if (rc != blocksize) {
int e = errno; Die("failed to write full blocksize");
fputs("dd: failed to write blocksize: ", stderr);
fputs(infile, stderr);
fputs("\n", stderr);
return __COUNTER__ + 1;
} }
} }
if (close(fdin) == -1) SysFail("close", infile); if (close(fdin) == -1) {
if (close(fdout) == -1) SysFail("close", oufile); DieSys(infile);
}
if (close(fdout) == -1) {
DieSys(oufile);
}
return 0; return 0;
} }