From: Andreas Dilger Date: Sat, 5 Aug 2006 18:41:00 +0000 (-0400) Subject: Create the generated files read-only to remind developers not to edit them. X-Git-Tag: E2FSPROGS-1_40-WIP-1114~73 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=3f5ef9642bc08bf2a9088a0ec58ec9b0abadf0a6;p=tools%2Fe2fsprogs.git Create the generated files read-only to remind developers not to edit them. Signed-off-by: Andreas Dilger Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/et/ChangeLog b/lib/et/ChangeLog index c8f63d2..2f7f0a5 100644 --- a/lib/et/ChangeLog +++ b/lib/et/ChangeLog @@ -1,3 +1,8 @@ +2006-08-05 Theodore Ts'o + + * compile_et.sh.in: Create the generated .c and .h files read-only + to remind developers they shouldn't edit them. + 2005-12-10 Theodore Ts'o * Makefile.in: Add a dependency to make sure that the diff --git a/lib/et/compile_et.sh.in b/lib/et/compile_et.sh.in index 27bb3cd..2cc296f 100644 --- a/lib/et/compile_et.sh.in +++ b/lib/et/compile_et.sh.in @@ -34,13 +34,15 @@ fi $AWK -f "${DIR}/et_h.awk" "outfile=${BASE}.h.$$" "outfn=${BASE}.h" "$ROOT.et" if test -f ${BASE}.h && cmp -s ${BASE}.h.$$ ${BASE}.h ; then - rm ${BASE}.h.$$ + rm -f ${BASE}.h.$$ else - mv ${BASE}.h.$$ ${BASE}.h + mv -f ${BASE}.h.$$ ${BASE}.h + chmod -w ${BASE}.h fi $AWK -f "${DIR}/et_c.awk" "outfile=${BASE}.c.$$" "outfn=${BASE}.c" "$ROOT.et" if test -f ${BASE}.c && cmp -s ${BASE}.c.$$ ${BASE}.c ; then - rm ${BASE}.c.$$ + rm -f ${BASE}.c.$$ else - mv ${BASE}.c.$$ ${BASE}.c + mv -f ${BASE}.c.$$ ${BASE}.c + chmod -w ${BASE}.c fi diff --git a/lib/ss/ChangeLog b/lib/ss/ChangeLog index 3a41491..34ec8a6 100644 --- a/lib/ss/ChangeLog +++ b/lib/ss/ChangeLog @@ -1,3 +1,8 @@ +2006-08-05 Theodore Tso + + * mk_cmds.sh.in: Create the generated .c files read-only to remind + developers they shouldn't edit them. + 2005-12-10 Theodore Ts'o * Makefile.in: Add a dependency to make sure that the diff --git a/lib/ss/mk_cmds.sh.in b/lib/ss/mk_cmds.sh.in index 303a73a..af44bc5 100644 --- a/lib/ss/mk_cmds.sh.in +++ b/lib/ss/mk_cmds.sh.in @@ -43,6 +43,7 @@ if grep "^#__ERROR_IN_FILE" "${TMP}" > /dev/null; then exit 1 else rm -f "${BASE}.c" - mv "${TMP}" "${BASE}.c" + mv -f "${TMP}" "${BASE}.c" + chmod -w "${BASE}.c" exit 0 fi diff --git a/util/ChangeLog b/util/ChangeLog index d345c90..59e95f4 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,8 @@ +2006-08-05 Andreas Dilger + + * subst.c (main): Create automatically-generated files be + read-only in order to remind developers not to end them. + 2005-10-26 Theodore Ts'o * Makefile.in: Use BUILD_CCFLAGS and BUILD_LDFLAGS instead of diff --git a/util/subst.c b/util/subst.c index 4c58b91..9244e62 100644 --- a/util/subst.c +++ b/util/subst.c @@ -367,6 +367,7 @@ int main(int argc, char **argv) fclose(in); fclose(out); if (outfn) { + struct stat st; if (compare_file(outfn, newfn)) { if (verbose) printf("No change, keeping %s.\n", outfn); @@ -386,6 +387,9 @@ int main(int argc, char **argv) printf("Creating or replacing %s.\n", outfn); rename(newfn, outfn); } + /* set read-only to alert user it is a generated file */ + if (stat(outfn, &st) == 0) + chmod(outfn, st.st_mode & ~0222); } return (0); }