xref: /dragonfly/bin/cpdup/hcproto.h (revision 5ca0a96d)
1 /*
2  * HCPROTO.H
3  */
4 
5 #ifndef _HCPROTO_H_
6 #define _HCPROTO_H_
7 
8 #define HCPROTO_VERSION		6
9 #define HCPROTO_VERSION_COMPAT	2
10 #define HCPROTO_VERSION_LUCC	6	/* lutimes, lchflags, lchmod */
11 
12 #define HC_HELLO	0x0001
13 
14 #define HC_STAT		0x0010
15 #define HC_LSTAT	0x0011
16 #define HC_OPENDIR	0x0012
17 #define HC_READDIR	0x0013
18 #define HC_CLOSEDIR	0x0014
19 #define HC_OPEN		0x0015
20 #define HC_CLOSE	0x0016
21 #define HC_READ		0x0017
22 #define HC_WRITE	0x0018
23 #define HC_REMOVE	0x0019
24 #define HC_MKDIR	0x001A
25 #define HC_RMDIR	0x001B
26 #define HC_CHOWN	0x001C
27 #define HC_LCHOWN	0x001D
28 #define HC_CHMOD	0x001E
29 #define HC_LINK		0x001F
30 #define HC_CHFLAGS	0x0020
31 #define HC_READLINK	0x0021
32 #define HC_UMASK	0x0022
33 #define HC_SYMLINK	0x0023
34 #define HC_RENAME	0x0024
35 #define HC_UTIMES	0x0025
36 #define HC_MKNOD	0x0026
37 #define HC_GETEUID	0x0027
38 #define HC_GETGROUPS	0x0028
39 #define HC_SCANDIR	0x0029
40 #define HC_READFILE	0x002A
41 #define HC_LUTIMES	0x002B
42 #define HC_LCHFLAGS	0x002C
43 #define HC_LCHMOD	0x002D
44 
45 #define LC_HELLOSTR	(0x0001|LCF_STRING)
46 #define LC_PATH1	(0x0010|LCF_STRING)
47 #define LC_PATH2	(0x0011|LCF_STRING)
48 #define LC_OFLAGS	(0x0012|LCF_INT32)
49 #define LC_MODE		(0x0013|LCF_INT32)
50 #define LC_BYTES	(0x0014|LCF_INT32)
51 #define LC_OWNER	(0x0015|LCF_INT32)
52 #define LC_GROUP	(0x0016|LCF_INT32)
53 #define LC_DEV		(0x0017|LCF_INT32)
54 #define LC_INO		(0x0018|LCF_INT64)
55 #define LC_NLINK	(0x0019|LCF_INT32)
56 #define LC_UID		(0x001A|LCF_INT32)
57 #define LC_GID		(0x001B|LCF_INT32)
58 #define LC_RDEV		(0x001C|LCF_INT32)
59 #define LC_ATIME	(0x001D|LCF_INT64)
60 #define LC_MTIME	(0x001E|LCF_INT64)
61 #define LC_CTIME	(0x001F|LCF_INT64)
62 #define LC_FILESIZE	(0x0020|LCF_INT64)
63 #define LC_FILEBLKS	(0x0021|LCF_INT64)
64 #define LC_FILEFLAGS	(0x0022|LCF_INT64)
65 #define LC_UNUSED23	(0x0023|LCF_INT64)
66 #define LC_DESCRIPTOR	(0x0024|LCF_INT32)
67 #define LC_DATA		(0x0025|LCF_BINARY)
68 #define LC_TYPE		(0x0026|LCF_INT32)
69 #define LC_BLKSIZE	(0x0027|LCF_INT32)
70 #define LC_VERSION	(0x0028|LCF_INT32)
71 #define LC_COUNT	(0x0029|LCF_INT32)
72 #define LC_ATIMENSEC	(0x002A|LCF_INT32)
73 #define LC_MTIMENSEC	(0x002B|LCF_INT32)
74 #define LC_CTIMENSEC	(0x002C|LCF_INT32)
75 
76 #define XO_NATIVEMASK	3		/* passed through directly */
77 #define XO_CREAT	0x00010000
78 #define XO_EXCL		0x00020000
79 #define XO_TRUNC	0x00040000
80 
81 #define HC_DESC_DIR	1
82 #define HC_DESC_FD	2
83 
84 #ifndef MAXNAMLEN
85 #define MAXNAMLEN	255
86 #endif
87 
88 struct HCDirEntry {
89 	char d_name[MAXNAMLEN + 1];
90 };
91 
92 int hc_connect(struct HostConf *hc, int readonly);
93 void hc_slave(int fdin, int fdout);
94 
95 int hc_hello(struct HostConf *hc);
96 int hc_stat(struct HostConf *hc, const char *path, struct stat *st);
97 int hc_lstat(struct HostConf *hc, const char *path, struct stat *st);
98 DIR *hc_opendir(struct HostConf *hc, const char *path);
99 struct HCDirEntry *hc_readdir(struct HostConf *hc, DIR *dir, struct stat **statpp);
100 int hc_closedir(struct HostConf *hc, DIR *dir);
101 int hc_open(struct HostConf *hc, const char *path, int flags, mode_t mode);
102 int hc_close(struct HostConf *hc, int fd);
103 ssize_t hc_read(struct HostConf *hc, int fd, void *buf, size_t bytes);
104 ssize_t hc_write(struct HostConf *hc, int fd, const void *buf, size_t bytes);
105 int hc_remove(struct HostConf *hc, const char *path);
106 int hc_mkdir(struct HostConf *hc, const char *path, mode_t mode);
107 int hc_rmdir(struct HostConf *hc, const char *path);
108 int hc_chown(struct HostConf *hc, const char *path, uid_t owner, gid_t group);
109 int hc_lchown(struct HostConf *hc, const char *path, uid_t owner, gid_t group);
110 int hc_chmod(struct HostConf *hc, const char *path, mode_t mode);
111 int hc_lchmod(struct HostConf *hc, const char *path, mode_t mode);
112 int hc_mknod(struct HostConf *hc, const char *path, mode_t mode, dev_t rdev);
113 int hc_link(struct HostConf *hc, const char *name1, const char *name2);
114 int hc_chflags(struct HostConf *hc, const char *path, u_long flags);
115 int hc_lchflags(struct HostConf *hc, const char *path, u_long flags);
116 int hc_readlink(struct HostConf *hc, const char *path, char *buf, int bufsiz);
117 mode_t hc_umask(struct HostConf *hc, mode_t numask);
118 int hc_symlink(struct HostConf *hc, const char *name1, const char *name2);
119 int hc_rename(struct HostConf *hc, const char *name1, const char *name2);
120 int hc_utimes(struct HostConf *hc, const char *path, const struct timeval *times);
121 int hc_lutimes(struct HostConf *hc, const char *path, const struct timeval *times);
122 uid_t hc_geteuid(struct HostConf *hc);
123 int hc_getgroups(struct HostConf *hc, gid_t **gidlist);
124 
125 #endif
126 
127