Re: [PATCH] 03/13 e2fsprogs-rdonlygen - make generated files read-only
Theodore Tso <[email protected]> Sat, 5 Aug 2006 14:44:34 -0400
| Newsgroups | gmane.comp.file-systems.ext2.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Aug 02, 2006 at 10:47:43AM -0600, Andreas Dilger wrote: > Make automatically-generated files read-only to avoid confusion when > developing. Having the file read-only is a reminder that it should > not be edited. Hi Andreas, The patch you submitted didn't actually change compile_et to create its generated files read-only, and it omitted fixing lib/ss's mk_cmds scripts. I ended up checking in the attached patch instead. (Insert stock reminder to add the Signed-off-by line; I'm relying on your e-mail giving me blanket permission to add the Signed-off line to patches from you, but I'd prefer if you added them yourself. :-) - Ted # HG changeset patch # User [email protected] # Date 1154803260 14400 # Node ID d67dde7a3c861b8092dbd8f7811039192a88ec36 # Parent 76bcbe906454c696c29874fab94a3da462829e51 Create the generated files read-only to remind developers not to edit them. Signed-off-by: Andreas Dilger <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]> diff -r 76bcbe906454 -r d67dde7a3c86 lib/et/ChangeLog --- a/lib/et/ChangeLog Sat Jul 15 22:08:20 2006 -0400 +++ b/lib/et/ChangeLog Sat Aug 05 14:41:00 2006 -0400 @@ -1,3 +1,8 @@ 2005-12-10 Theodore Ts'o <[email protected] +2006-08-05 Theodore Ts'o <[email protected]> + + * 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 <[email protected]> * Makefile.in: Add a dependency to make sure that the diff -r 76bcbe906454 -r d67dde7a3c86 lib/et/compile_et.sh.in --- a/lib/et/compile_et.sh.in Sat Jul 15 22:08:20 2006 -0400 +++ b/lib/et/compile_et.sh.in Sat Aug 05 14:41:00 2006 -0400 @@ -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 -r 76bcbe906454 -r d67dde7a3c86 lib/ss/ChangeLog --- a/lib/ss/ChangeLog Sat Jul 15 22:08:20 2006 -0400 +++ b/lib/ss/ChangeLog Sat Aug 05 14:41:00 2006 -0400 @@ -1,3 +1,8 @@ 2005-12-10 Theodore Ts'o <[email protected] +2006-08-05 Theodore Tso <[email protected]> + + * 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 <[email protected]> * Makefile.in: Add a dependency to make sure that the diff -r 76bcbe906454 -r d67dde7a3c86 lib/ss/mk_cmds.sh.in --- a/lib/ss/mk_cmds.sh.in Sat Jul 15 22:08:20 2006 -0400 +++ b/lib/ss/mk_cmds.sh.in Sat Aug 05 14:41:00 2006 -0400 @@ -43,6 +43,7 @@ if grep "^#__ERROR_IN_FILE" "${TMP}" > / exit 1 else rm -f "${BASE}.c" - mv "${TMP}" "${BASE}.c" + mv -f "${TMP}" "${BASE}.c" + chmod -w "${BASE}.c" exit 0 fi diff -r 76bcbe906454 -r d67dde7a3c86 util/ChangeLog --- a/util/ChangeLog Sat Jul 15 22:08:20 2006 -0400 +++ b/util/ChangeLog Sat Aug 05 14:41:00 2006 -0400 @@ -1,3 +1,8 @@ 2005-10-26 Theodore Ts'o <[email protected] +2006-08-05 Andreas Dilger <[email protected]> + + * 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 <[email protected]> * Makefile.in: Use BUILD_CCFLAGS and BUILD_LDFLAGS instead of diff -r 76bcbe906454 -r d67dde7a3c86 util/subst.c --- a/util/subst.c Sat Jul 15 22:08:20 2006 -0400 +++ b/util/subst.c Sat Aug 05 14:41:00 2006 -0400 @@ -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); } ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV