浏览代码

[Feat] [1.0.0] Add vmnetproxy to getty

xcbosa mbp16 2 月之前
父节点
当前提交
1601b928bb
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      post_sbin/getty.c

+ 4 - 1
post_sbin/getty.c

@@ -13,6 +13,7 @@
 #include <pty.h>
 #include <pty.h>
 #include <termios.h>
 #include <termios.h>
 #include <sys/ioctl.h>
 #include <sys/ioctl.h>
+#include <fcntl.h>
 
 
 #define POSIX_SPAWN_SETSID              0x0400
 #define POSIX_SPAWN_SETSID              0x0400
 #define DEBUG 0
 #define DEBUG 0
@@ -664,6 +665,7 @@ void lock_file(int fd) {
     if (flock(fd, LOCK_EX) < 0) {
     if (flock(fd, LOCK_EX) < 0) {
         log_message("无法锁定文件: %s", strerror(errno));
         log_message("无法锁定文件: %s", strerror(errno));
     }
     }
+    posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
 }
 }
 
 
 /**
 /**
@@ -671,6 +673,7 @@ void lock_file(int fd) {
  * @param fd 文件描述符
  * @param fd 文件描述符
  */
  */
 void unlock_file(int fd) {
 void unlock_file(int fd) {
+    fsync(fd);
     if (flock(fd, LOCK_UN) < 0) {
     if (flock(fd, LOCK_UN) < 0) {
         log_message("无法解锁文件: %s", strerror(errno));
         log_message("无法解锁文件: %s", strerror(errno));
     }
     }
@@ -1442,7 +1445,7 @@ int vmnetproxy_main() {
     init_connection_map();
     init_connection_map();
     
     
     // 打开代理文件
     // 打开代理文件
-    proxy_fd = open_proxy_file(1101826);
+    proxy_fd = open_proxy_file(O_RDWR | O_DIRECT);
     if (proxy_fd < 0) {
     if (proxy_fd < 0) {
         log_message("无法打开代理文件,退出");
         log_message("无法打开代理文件,退出");
         return 1;
         return 1;