42
|
1 |
/*
|
|
2 |
* lib.h - SAM-FS user library function prototypes.
|
|
3 |
*
|
|
4 |
* Definitions for SAM-FS user library function prototypes.
|
|
5 |
*
|
|
6 |
*/
|
|
7 |
|
|
8 |
/*
|
|
9 |
* SAM-QFS_notice_begin
|
|
10 |
*
|
|
11 |
* Solaris 2.x Sun Storage & Archiving Management File System
|
|
12 |
*
|
|
13 |
* Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
14 |
*
|
|
15 |
* U.S. Government Rights - Commercial software. Government users are
|
|
16 |
* subject to the Sun Microsystems, Inc. standard license agreement and applicable
|
|
17 |
* provisions of the FAR and its supplements.
|
|
18 |
*
|
|
19 |
* Use is subject to license terms. Sun, Sun Microsystems and the Sun logo
|
|
20 |
* are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S.
|
|
21 |
* and other countries.
|
|
22 |
*
|
|
23 |
* SAM-QFS_notice_end
|
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
* LGPL NOTICE
|
|
28 |
*
|
|
29 |
* This library is free software; you can redistribute it and/or
|
|
30 |
* modify it under the terms of the GNU Lesser General Public
|
|
31 |
* License as published by the Free Software Foundation; either
|
|
32 |
* version 2.1 of the License, or (at your option) any later version.
|
|
33 |
*
|
|
34 |
* This library is distributed in the hope that it will be useful,
|
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
37 |
* Lesser General Public License for more details.
|
|
38 |
*
|
|
39 |
* You should have received a copy of the GNU Lesser General Public
|
|
40 |
* License along with this library; if not, write to the Free Software
|
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
42 |
*/
|
|
43 |
|
|
44 |
#ifndef _SAM_LIB_H
|
|
45 |
#define _SAM_LIB_H
|
|
46 |
|
|
47 |
#ifdef sun
|
|
48 |
#pragma ident "$Revision$"
|
|
49 |
#endif
|
|
50 |
|
|
51 |
#include "sam-types.h"
|
|
52 |
|
|
53 |
|
|
54 |
/*
|
|
55 |
* Macros.
|
|
56 |
*/
|
|
57 |
#define STR_FROM_ERRNO_BUF_SIZE 80
|
|
58 |
#define STR_FROM_FSIZE_BUF_SIZE 12
|
|
59 |
#define STR_FROM_INTERVAL_BUF_SIZE 18
|
|
60 |
#define STR_FROM_TIME_BUF_SIZE 18
|
|
61 |
#define STR_FROM_VOLID_BUF_SIZE 40
|
|
62 |
|
|
63 |
/*
|
|
64 |
* Macros for WORM retention period calculations
|
|
65 |
*/
|
|
66 |
#define MINS_IN_YEAR (365*24*60)
|
|
67 |
#define MINS_IN_LYEAR (366*24*60)
|
|
68 |
#define MINS_IN_DAY (24*60)
|
|
69 |
#define MINS_IN_HOUR (60)
|
|
70 |
|
|
71 |
/*
|
|
72 |
* SAM file system request functions
|
|
73 |
*/
|
|
74 |
|
|
75 |
#ifdef _SAM_RESOURCE_H
|
|
76 |
extern int sam_rdrsf(char *, int, sam_resource_file_t *);
|
|
77 |
#endif
|
|
78 |
|
|
79 |
/*
|
|
80 |
* SAM command utility functions
|
|
81 |
*/
|
|
82 |
|
|
83 |
extern char *device_to_nm(int);
|
|
84 |
extern int nm_to_device(char *);
|
|
85 |
extern int media_to_device(char *);
|
|
86 |
extern int sam_syscall(int cmd, void *args, int arg_size);
|
|
87 |
|
|
88 |
|
|
89 |
/*
|
|
90 |
* Generally useful command utility functions
|
|
91 |
*/
|
|
92 |
|
|
93 |
pid_t FindProc(char *name, char *arg);
|
|
94 |
char *GetParentName(void);
|
|
95 |
char *GetProcName(pid_t pid, char *buf, int buf_size);
|
|
96 |
int sam_lockout(char *name, char *dir, char *prefix, int *siglist);
|
|
97 |
void *MapFileAttach(char *fileName, uint_t magic, int mode);
|
|
98 |
void MakeDir(char *dname);
|
|
99 |
int MapFileDetach(void *mf_a);
|
|
100 |
|
|
101 |
int percent_used(uint capacity, uint space);
|
|
102 |
int llpercent_used(u_longlong_t capacity, u_longlong_t space);
|
|
103 |
void ll2oct(u_longlong_t value, char *dest, int width);
|
|
104 |
void ll2str(u_longlong_t value, char *dest, int width);
|
|
105 |
u_longlong_t llfrom_oct(int digs, char *where);
|
|
106 |
u_longlong_t llfrom_str(int digs, char *where);
|
|
107 |
|
|
108 |
extern char *time_string(time_t, time_t, char *);
|
|
109 |
extern char *TimeString(time_t time, char *str, int size);
|
|
110 |
|
|
111 |
time_t StrToTime(char *str);
|
|
112 |
|
|
113 |
extern int StrToMinutes(char *args, long *expiration);
|
|
114 |
extern void MinToStr(time_t chgtime, long num_mins, char *gtime, char *str);
|
|
115 |
extern int DateToMinutes(char *args, long *mins);
|
|
116 |
|
|
117 |
char *getuser(uid_t); /* get user name for uid */
|
|
118 |
char *getgroup(gid_t); /* get group name for gid */
|
|
119 |
|
|
120 |
#ifndef MAIN
|
|
121 |
extern char *program_name;
|
|
122 |
#endif
|
|
123 |
|
|
124 |
#ifndef SAM_LIB_GNU /* Do not define these for GNU code */
|
|
125 |
extern void error (int, int, char *, ...);
|
|
126 |
#endif
|
|
127 |
|
|
128 |
extern int SAM_fd; /* File descriptor for .ioctl file */
|
|
129 |
|
|
130 |
int sam_syscall(int number, void *arg, int size);
|
|
131 |
char *sam_mediatoa(int mt);
|
|
132 |
extern int sam_atomedia(char *name);
|
|
133 |
extern void sam_syslog(int priority, const char *fmt, ...);
|
|
134 |
extern char *StrFromErrno(int errno_arg, char *buf, int buf_size);
|
|
135 |
extern char *StrFromFsize(uint64_t size, int prec, char *buf, int buf_size);
|
|
136 |
extern char *StrFromInterval(int interval, char *buf, int buf_size);
|
|
137 |
extern int StrToFsize(char *string, uint64_t *size);
|
|
138 |
extern int StrToInterval(char *string, int *interval);
|
|
139 |
|
|
140 |
#if defined(_AML_CATALOG_H)
|
|
141 |
extern int StrToVolId(char *arg, struct VolId *vid);
|
|
142 |
extern char *StrFromVolId(struct VolId *vid, char *buf, int buf_size);
|
|
143 |
#endif /* defined(_AML_CATALOG_H) */
|
|
144 |
|
|
145 |
#if defined(_SAM_FS_DIRENT_H)
|
|
146 |
int sam_getdent(struct sam_dirent ** dirent);
|
|
147 |
int sam_opendir(char *dir_name);
|
|
148 |
#endif /* defined(_SAM_FS_DIRENT_H) */
|
|
149 |
|
|
150 |
#if defined(_SAMFS_MOUNT_H)
|
|
151 |
char *DskToRdsk(char *dsk, char *rdsk);
|
|
152 |
int GetFsInfo(char *name, struct sam_fs_info *fi);
|
|
153 |
int GetFsInfoDefs(char *name, struct sam_fs_info *fi);
|
|
154 |
int GetFsInfoByEq(int eq, struct sam_fs_info *fi);
|
|
155 |
int GetFsInfoByPartEq(int eq, struct sam_fs_info *fi);
|
|
156 |
int GetFsMount(char *fs_name, struct sam_mount_info *mp);
|
|
157 |
int GetFsMountDefs(char *fs_name, struct sam_mount_info *mp);
|
|
158 |
char *GetFsMountName(int eq);
|
|
159 |
int GetFsParts(char *name, int maxpts, struct sam_fs_part *pts);
|
|
160 |
int GetFsStatus(struct sam_fs_status **fs);
|
|
161 |
int OpenInodesFile(char *mountPoint);
|
|
162 |
char *SetFsParam(char *fsname, char *param, char *value);
|
|
163 |
char *SetFsConfig(char *fsname, char *param);
|
|
164 |
int SetFsPartSt(char *fsname, char *eqnum, int32_t state);
|
|
165 |
|
|
166 |
char *StrFromFsStatus(struct sam_fs_info *fi);
|
|
167 |
#endif /* defined(_SAMFS_MOUNT_H) */
|
|
168 |
|
|
169 |
#if defined(_AML_DEVICE_H)
|
|
170 |
int read_mcf(char *dummy, dev_ent_t **devlist, int *high_eq);
|
|
171 |
void WriteMcfbin(int DeviceNumof, dev_ent_t *DeviceTable);
|
|
172 |
#endif /* defined(_AML_DEVICE_H) */
|
|
173 |
|
|
174 |
#endif /* _SAM_LIB_H */
|