/[LeafOK_CVS]/lbbs/src/data_file_mgr.c
ViewVC logotype

Diff of /lbbs/src/data_file_mgr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 by sysadm, Fri Nov 7 13:56:11 2025 UTC Revision 1.2 by sysadm, Fri Nov 7 14:44:47 2025 UTC
# Line 192  int data_file_mgr(void *param) Line 192  int data_file_mgr(void *param)
192                  break;                  break;
193          }          }
194    
195            if (SYS_server_exit) // Do not save data on shutdown
196            {
197                    goto cleanup;
198            }
199    
200          if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0)          if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0)
201          {          {
202                  log_error("open(%s) error (%d)\n", path, errno);                  log_error("open(%s) error (%d)\n", path, errno);
# Line 210  int data_file_mgr(void *param) Line 215  int data_file_mgr(void *param)
215                  fd = -1;                  fd = -1;
216                  goto cleanup;                  goto cleanup;
217          }          }
         fd = -1;  
218    
219          if (unlink(data_file_list[i].path) < 0)          // Make another copy of the data file so that the user editored copy will be kept after upgrade / reinstall
220            if ((fd = open(data_file_list[i].path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0)
221          {          {
222                  log_error("unlink(%s) error (%d)\n", data_file_list[i].path, errno);                  log_error("open(%s) error (%d)\n", data_file_list[i].path, errno);
223                  goto cleanup;                  goto cleanup;
224          }          }
225    
226          if (link(path, data_file_list[i].path) < 0)          if (write(fd, p_data_new, (size_t)len_data_new) < 0)
227          {          {
228                  log_error("link(%s, %s) error (%d)\n", path, data_file_list[i].path, errno);                  log_error("write(len=%ld) error (%d)\n", len_data_new, errno);
229                  goto cleanup;                  goto cleanup;
230          }          }
231    
232            if (close(fd) < 0)
233            {
234                    log_error("close(fd) error (%d)\n", errno);
235                    fd = -1;
236                    goto cleanup;
237            }
238            fd = -1;
239    
240          clearscr();          clearscr();
241          moveto(1, 1);          moveto(1, 1);
242          prints("修改已完成,需要重新加载配置后才会生效...");          prints("修改已完成,需要重新加载配置后才会生效...");


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1