• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef INIT_SERVICE_FILE_
16 #define INIT_SERVICE_FILE_
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <sys/types.h>
20 #include <unistd.h>
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif
26 
27 #define FILE_OPT_NUMS 5
28 #define SERVICE_FILE_NAME 0
29 #define SERVICE_FILE_FLAGS 1
30 #define SERVICE_FILE_PERM 2
31 #define SERVICE_FILE_UID 3
32 #define SERVICE_FILE_GID 4
33 
34 typedef struct ServiceFile_ {
35     struct ServiceFile_ *next;
36     int flags;
37     uid_t uid;     // uid
38     gid_t gid;     // gid
39     mode_t perm;   // Setting permissions
40     int fd;
41     char fileName[0];
42 } ServiceFile;
43 
44 void CreateServiceFile(ServiceFile *fileOpt);
45 void CloseServiceFile(ServiceFile *fileOpt);
46 
47 #ifdef __cplusplus
48 #if __cplusplus
49 }
50 #endif
51 #endif
52 #endif
53