Commit Graph

9 Commits

Author SHA1 Message Date
David Hendricks
4b680119cc file_lock: Add fallback directory
This adds a fallback directory in case SYSTEM_LOCKFILE_DIR is
unavailable. Since this is a band-aid meant to help older systems
auto-update, the fallback path is hardcoded to "/tmp" as to avoid
polluting the overall lockfile API.

BUG=chromium:616620
BRANCH=none
TEST=Tested on veyron_jaq by removing /run/lock and seeing
mosys, flashrom, and ectool run successfully with
firmware_utility_lock in /tmp.

Change-Id: Idbe63a574474ec35a5c3b6fe2b0fb3b672941492
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/348850
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2016-06-02 17:02:51 -07:00
David Hendricks
ad7d6516b5 locks: Update lockfile dir to be FHS 3.0 compliant
The Filesystem Hierarchy Standard version 3.0* specifies that /run
should be used for runtime variables such as locks.

The rationale for switching to use /run instead of /var/run was
because /var might not be available at early boot. Since /run is
implemented as a tmpfs and doesn't require /var to be mounted first
it can be made available earlier.

*http://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html

BUG=chromium:591366
BRANCH=none
TEST=none

Change-Id: Ic0b5ff336c1c258db8891c0a17c836497d9793c5
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/330123
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-02 18:03:45 -08:00
David Hendricks
d89301b036 Replace SysV semaphore lock with file lock
Some systems, such as Android, do not support SysV semaphore locks.
This implements an alternative file lock mechanism using flock().

flock() was chosen because it's pretty straight forward. It's known to
be broken when using NFS, but I doubt we'll ever store our lock on an
NFS volume.

CQ-DEPEND=CL:327407,CL:325609
BUG=chrome-os-partner:49527
BRANCH=none
TEST=tested on Smaug by running mosys and ectool while reading
firmware ROM with flashrom, all three utilities eventually
ran successfully.

Change-Id: Ic73fe0281fbc1dfaae1bb03e5683774a0c04ae5b
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/329430
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-01 14:53:50 -08:00
David Hendricks
7b43197449 Add library for working with Android
This adds a couple of helper functions for working within Android:
- in_android(): Crude test that uses getenv() to see if an Android-
specific environment variable is defined.

- android_tmpdir_path(): Android doesn't have the usual locations for
temporary file storage such as /tmp or even /var/run/locks. And to
make matters worse, there isn't even a standard location for
temporary files so it must be determined at run time.

This will be used in a follow-up patch.

BUG=chrome-os-partner:49527
BRANCH=none
TEST=tested on smaug

Change-Id: Ifb5fb4067fffb7c8cb2d4350ca4a223e884d3aa5
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/329299
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-29 18:20:07 -08:00
Anatol Pomazau
e4565cca1a Add bionic compatibility
TEST=Build ectool for Android and run it
BUG=None
BRANCH=master

Signed-off-by: Anatol Pomazau <anatol@google.com>

Change-Id: I5f148adfc24591523a7d8c50817c8095072071c3
Reviewed-on: https://chromium-review.googlesource.com/327220
Commit-Ready: Anatol Pomazau <anatol@google.com>
Tested-by: Anatol Pomazau <anatol@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-10 18:19:24 -08:00
Bill Richardson
104f811e67 cleanup: fix all the header guards
This unifies all the EC header files to use __CROS_EC_FILENAME_H
as the include guard. Well, except for test/ util/ and extra/
which use __TEST_ __UTIL_ and __EXTRA_ prefixes respectively.

BUG=chromium:496895
BRANCH=none
TEST=make buildall -j

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: Iea71b3a08bdec94a11239de810a2b2e152b15029
Reviewed-on: https://chromium-review.googlesource.com/278121
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-06-18 19:07:00 +00:00
Randall Spangler
6ab8e91658 cleanup: Remove checkpatch warnings
This make minor syntactic changes and renames some camel-cased symbols
to keep checkpatch from complaining.  The goal is to reduce the
temptation to use 'repo upload --no-verify'.

This is a big furball of find/replace, but no functional changes.

BUG=chromium:322144
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I0269b7dd95836ef9a6e33f88c003ab0f24f842a0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/180495
2013-12-19 00:12:28 +00:00
Vincent Palatin
4b59746600 util: declare all host utils source dependencies in build.mk
Instead of hardcoding the common files for host utils in the generic
rules, let's declare them in the build.mk file using the same system as
the Linux kernel build.

if a binary "foo" declared in "host-util-bin" or "build-util-bin" has a
matching "foo-objs" variable, it will be build from all objects declared
in "foo-objs" else it uses directly "foo.o" (single source file).

This is preparatory to add new "build" tools sharing common sources.

note: the dependencies on the utils are a bit less fine-grained as a
result of this change, but given the low number of tools, that should be
acceptable.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=none
TEST=./util/make_all.sh

Change-Id: Ieffce7ca6f5b685ffb7d1f4626b99aff07b61443
Reviewed-on: https://chromium-review.googlesource.com/176174
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2013-11-14 17:52:39 +00:00
Louis Yung-Chieh Lo
03d4ed278d Add GEC lock mechanism.
Basically re-use the gec lock code from flashrom package.

BUG=chrome-os-partner:12319
TEST=Build and run on link. Only build on snow.
while true; do ectool hello; done &   ; run 10 instances.
                                      ; expect all instances runs okay.

Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: I11d5824f46810c6f5a04a564a81387cdea081697
Reviewed-on: https://gerrit.chromium.org/gerrit/29763
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-08-10 09:28:34 -07:00