Whamcloud - gitweb
Create the generated files read-only to remind developers not to edit them.
authorAndreas Dilger <adilger@clusterfs.com>
Sat, 5 Aug 2006 18:41:00 +0000 (14:41 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 5 Aug 2006 18:41:00 +0000 (14:41 -0400)
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/et/ChangeLog
lib/et/compile_et.sh.in
lib/ss/ChangeLog
lib/ss/mk_cmds.sh.in
util/ChangeLog
util/subst.c

index c8f63d2..2f7f0a5 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-05  Theodore Ts'o  <tytso@mit.edu>
+
+       * 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  <tytso@mit.edu>
 
        * Makefile.in: Add a dependency to make sure that the
index 27bb3cd..2cc296f 100644 (file)
@@ -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
index 3a41491..34ec8a6 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-05  Theodore Tso  <tytso@mit.edu>
+
+       * 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  <tytso@mit.edu>
 
        * Makefile.in: Add a dependency to make sure that the
index 303a73a..af44bc5 100644 (file)
@@ -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
index d345c90..59e95f4 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-05  Andreas Dilger <adilger@clusterfs.com>
+
+       * 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  <tytso@mit.edu>
 
        * Makefile.in: Use BUILD_CCFLAGS and BUILD_LDFLAGS instead of
index 4c58b91..9244e62 100644 (file)
@@ -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);
 }