[PATCH] 03/13 e2fsprogs-rdonlygen - make generated files read-only
Andreas Dilger <[email protected]> Wed, 2 Aug 2006 10:47:43 -0600
| Newsgroups | gmane.comp.file-systems.ext2.devel |
|---|---|
| Message-ID | <[email protected]> |
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.
Index: e2fsprogs/lib/et/compile_et.sh.in
===================================================================
--- e2fsprogs.orig/lib/et/compile_et.sh.in 2006-02-09 16:08:13.000000000 -0500
+++ e2fsprogs/lib/et/compile_et.sh.in 2006-07-19 11:52:09.000000000 -0400
@@ -34,13 +34,13 @@ 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
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
fi
Index: e2fsprogs/util/subst.c
===================================================================
--- e2fsprogs.orig/util/subst.c 2006-02-09 16:08:13.000000000 -0500
+++ e2fsprogs/util/subst.c 2006-07-19 11:47:52.000000000 -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);
}
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
-------------------------------------------------------------------------
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