HedongGao opened a new pull request, #17705:
URL: https://github.com/apache/nuttx/pull/17705

   
   ## Summary
   
   In some scenarios, we only want to configure device related properties 
through ioctl, and do not want to rely on other protocols, so we abstract a 
g_ctrl_sockif.
   
   ## Impact
   
   When users want to set dev related ioctl, they do not need to rely on other 
protocols.
   
   ## Testing
   
   `
   #include <stdio.h>
   #include <sys/socket.h>
   #include <sys/ioctl.h>
   #include <errno.h>
   #include <assert.h>
   #include <unistd.h>
   
   int main(void)
   {
       int sockfd;
       int ret;
       int dummy = 0;
   
       // Create a control socket
       sockfd = socket(AF_UNSPEC, SOCK_CTRL, 0);
       if (sockfd < 0)
       {
           perror("socket(SOCK_CTRL)");
           printf("Test FAILED: Could not create control socket\n");
           return 1;
       }
       printf("Control socket created: fd=%d\n", sockfd);
   
       // Try an ioctl operation (should fail with ENOTTY or ENOSYS if not 
implemented)
       ret = ioctl(sockfd, 0x1234, &dummy);
       if (ret < 0)
       {
           printf("ioctl returned error as expected: %d (%s)\n", errno, 
strerror(errno));
           // Acceptable: ENOTTY, ENOSYS, or other not supported
       }
       else
       {
           printf("ioctl returned success (unexpected for unimplemented 
command)\n");
       }
   
       // Close the control socket
       if (close(sockfd) < 0)
       {
           perror("close");
           printf("Test FAILED: Could not close control socket\n");
           return 1;
       }
   
       printf("Test PASSED: g_ctrl_sockif setup/close and ioctl behavior 
checked\n");
       return 0;
   }
   `
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to