util.h revision 44b65d047cc39baf30e21bfd8dd438f6bc1f77f5
13899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross/*
23899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross * Copyright (C) 2010 The Android Open Source Project
33899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross *
43899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross * Licensed under the Apache License, Version 2.0 (the "License");
53899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross * you may not use this file except in compliance with the License.
63899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross * You may obtain a copy of the License at
73899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross *
83899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross *      http://www.apache.org/licenses/LICENSE-2.0
93899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross *
103899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross * Unless required by applicable law or agreed to in writing, software
113899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross * distributed under the License is distributed on an "AS IS" BASIS,
123899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross * See the License for the specific language governing permissions and
143899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross * limitations under the License.
153899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross */
163899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross
173899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross#ifndef _INIT_UTIL_H_
183899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross#define _INIT_UTIL_H_
193899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross
20f83d0b9af5cbe4440cc41ceaa8a7806a13c86282Colin Cross#include <sys/stat.h>
21f83d0b9af5cbe4440cc41ceaa8a7806a13c86282Colin Cross#include <sys/types.h>
22f83d0b9af5cbe4440cc41ceaa8a7806a13c86282Colin Cross
2344b65d047cc39baf30e21bfd8dd438f6bc1f77f5Colin Cross#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
2444b65d047cc39baf30e21bfd8dd438f6bc1f77f5Colin Cross
25f83d0b9af5cbe4440cc41ceaa8a7806a13c86282Colin Crossstatic const char *coldboot_done = "/dev/.coldboot_done";
26f83d0b9af5cbe4440cc41ceaa8a7806a13c86282Colin Cross
273899e9fc01cf608f19f716749c54cc5c4d17e766Colin Crossint mtd_name_to_number(const char *name);
283899e9fc01cf608f19f716749c54cc5c4d17e766Colin Crossint create_socket(const char *name, int type, mode_t perm,
293899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross                  uid_t uid, gid_t gid);
303899e9fc01cf608f19f716749c54cc5c4d17e766Colin Crossvoid *read_file(const char *fn, unsigned *_sz);
313899e9fc01cf608f19f716749c54cc5c4d17e766Colin Crosstime_t gettime(void);
323899e9fc01cf608f19f716749c54cc5c4d17e766Colin Crossunsigned int decode_uid(const char *s);
333899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross
34b0ab94b7d5a888f0b6920b156e5c6a075fa0741aColin Crossint mkdir_recursive(const char *pathname, mode_t mode);
35b0ab94b7d5a888f0b6920b156e5c6a075fa0741aColin Crossvoid sanitize(char *p);
36b0ab94b7d5a888f0b6920b156e5c6a075fa0741aColin Crossvoid make_link(const char *oldpath, const char *newpath);
37b0ab94b7d5a888f0b6920b156e5c6a075fa0741aColin Crossvoid remove_link(const char *oldpath, const char *newpath);
38cd0f173e2790ee068fd2a20bcfc6c20468e97e51Colin Crossint wait_for_file(const char *filename, int timeout);
39f83d0b9af5cbe4440cc41ceaa8a7806a13c86282Colin Crossvoid open_devnull_stdio(void);
40f83d0b9af5cbe4440cc41ceaa8a7806a13c86282Colin Crossvoid get_hardware_name(char *hardware, unsigned int *revision);
413899e9fc01cf608f19f716749c54cc5c4d17e766Colin Cross#endif
42