mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:12:45 +00:00 
			
		
		
		
	Kernel: Support sending filedescriptors with sendmsg(2) and SCM_RIGHTS
This is necessary to support the wayland protocol. I also moved the CMSG_* macros to the kernel API since they are used in both kernel and userspace. this does not break ntpquery/SCM_TIMESTAMP.
This commit is contained in:
		
							parent
							
								
									ae5d7f542c
								
							
						
					
					
						commit
						f20902deb3
					
				
					 5 changed files with 97 additions and 37 deletions
				
			
		|  | @ -81,6 +81,32 @@ struct msghdr { | |||
|     int msg_flags; | ||||
| }; | ||||
| 
 | ||||
| // These three are non-POSIX, but common:
 | ||||
| #define CMSG_ALIGN(x) (((x) + sizeof(void*) - 1) & ~(sizeof(void*) - 1)) | ||||
| #define CMSG_SPACE(x) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(x)) | ||||
| #define CMSG_LEN(x) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (x)) | ||||
| 
 | ||||
| static inline struct cmsghdr* CMSG_FIRSTHDR(struct msghdr* msg) | ||||
| { | ||||
|     if (msg->msg_controllen < sizeof(struct cmsghdr)) | ||||
|         return (struct cmsghdr*)0; | ||||
|     return (struct cmsghdr*)msg->msg_control; | ||||
| } | ||||
| 
 | ||||
| static inline struct cmsghdr* CMSG_NXTHDR(struct msghdr* msg, struct cmsghdr* cmsg) | ||||
| { | ||||
|     struct cmsghdr* next = (struct cmsghdr*)((char*)cmsg + CMSG_ALIGN(cmsg->cmsg_len)); | ||||
|     unsigned offset = (char*)next - (char*)msg->msg_control; | ||||
|     if (msg->msg_controllen < offset + sizeof(struct cmsghdr)) | ||||
|         return (struct cmsghdr*)0; | ||||
|     return next; | ||||
| } | ||||
| 
 | ||||
| static inline void* CMSG_DATA(struct cmsghdr* cmsg) | ||||
| { | ||||
|     return (void*)(cmsg + 1); | ||||
| } | ||||
| 
 | ||||
| struct sockaddr { | ||||
|     sa_family_t sa_family; | ||||
|     char sa_data[14]; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Peter Elliott
						Peter Elliott