olpc-utils: hwinfo and reading mfg-data
pgf at laptop.org
Mon Aug 15 16:44:44 EDT 2011
> Hi Paul,
> I reworked your olpc-hwinfo slightly, refactored all the utilities
> reading /ofw . See
> My only concern is that it can't tell you whether ak/wp/ww tags
> _exist_. It can read values, but empty tags return the same as a
> missing tag.
this information is easy to provide by using an exit code to mean
"missing". probably should have done that in the first place.
untested patch below.
> You may also note that the shell functions don't add a
i think this is unnecessary, though i guess it's harmless. the shell
will remove the added newline during expansion in any case, so its
presence or absence doesn't really matter. likewise, per your comment,
remove null characters is unnecessary.
i seem to have used spaces, and you used tabs. either is fine with me,
but we should make it uniform with one more commit.
also, olpc-hwinfo (and therefore the function library as well) should
technically be in /usr/sbin. but that's a pretty thin hair to split.
diff --git a/usr/bin/olpc-hwinfo b/usr/bin/olpc-hwinfo
index b657476..0d43c40 100644
@@ -22,15 +22,15 @@ model)
- get_xo_mfg_tag SN
+ get_xo_mfg_tag SN || exit 1
- get_xo_mfg_tag "U#"
+ get_xo_mfg_tag "U#" || exit 1
- get_xo_mfg_tag "$2"
+ get_xo_mfg_tag "$2" || exit 1
diff --git a/usr/share/olpc-utils/olpc-utils-functions b/usr/share/olpc-utils/olpc-utils-functions
index 2329111..0e36b9c 100644
@@ -50,8 +50,12 @@ get_xo_mfg_tag()
elif [ -d /ofw/mfg-data ]
+ return 1
+ test -e $mfgdata/$tag || return 1
# do we need to strip leading nulls here?
# ie: cat $mfgdata/$tag | tr -d '\000' 2>/dev/null
cat $mfgdata/$tag 2>/dev/null
paul fox, pgf at laptop.org
More information about the Devel