[Mew-dist 03374] Re: imget when file system full

Motonori Nakamura motonori at example.com
1998年 1月 14日 (水) 07:13:23 JST


>>>>> On Tue, 13 Jan 1998 15:36:02 +0900, Atsushi Onoe <onoe at example.com> said:

onoe> 失われた場合に取り返しのつかない Mail という特性を考えるならば、
onoe> むしろ書き込みの際は常に close(2) の前に fsync(2) としても良いよ
onoe> うに思います。

onoe> 私なら、高速化のために fsync(2) を省略する方を optional -- at
onoe> your own risk としたいですね。

こんなかんじにしてみました。syscall.ph が p2ph されてなくて悲しかったり
する場合もあるだろうから、見つからなかったら syscall.h を見に行くように
しています。これで件の環境においてうまくチェックできるかしら。

- motonori

diff -c ../../im-81-/IM.in/Config.pm.in ./Config.pm.in
*** ../../im-81-/IM.in/Config.pm.in	Mon Dec 15 16:25:37 1997
--- ./Config.pm.in	Wed Jan 14 05:16:51 1998
***************
*** 40,46 ****
      home_dir conf_dir mail_dir mail_path news_dir news_path
      inbox_folder draft_folder trash_folder
      preserve_dot
!     folder_mode msg_mode allowcrlf
      aliases_file context_file
      address addresses_regex
      msgdbfile msgdbtype getsbrfile scansbrfile petnamefile
--- 40,46 ----
      home_dir conf_dir mail_dir mail_path news_dir news_path
      inbox_folder draft_folder trash_folder
      preserve_dot
!     folder_mode msg_mode allowcrlf no_sync
      aliases_file context_file
      address addresses_regex
      msgdbfile msgdbtype getsbrfile scansbrfile petnamefile
***************
*** 153,158 ****
--- 153,159 ----
      'trashfolder;f;;TrashFolder'	=> 'Trash folder',
      'foldermode;i;;FolderMode'		=> 'Folder directory mode when created',
      'msgmode;i;;MsgMode'		=> 'Message file mode when created',
+     'nosync;b;;NoSync'		=> 'Do not need fsync(2) on writing file',
      'allowcrlf;b;;AllowCRLF'		=> 'CRLF may be in saved message',
      'preservedot;b;;PreserveDot'	=> 'Not substitute "." with "/"',
      'contextfile;s;Context;ContextFile'	=> 'Context file',
***************
*** 762,767 ****
--- 763,772 ----
  
  sub allowcrlf () {
      return $AllowCRLF;
+ }
+ 
+ sub no_sync () {
+     return $NoSync;
  }
  
  sub context_file () {
diff -c ../../im-81-/IM.in/MsgStore.pm.in ./MsgStore.pm.in
*** ../../im-81-/IM.in/MsgStore.pm.in	Mon Dec 15 16:25:38 1997
--- ./MsgStore.pm.in	Wed Jan 14 05:55:28 1998
***************
*** 42,48 ****
  
  =cut
  
! use vars qw($MsgNum $First $Last $PrevDst);
  BEGIN {
      $MsgNum = 0;
      $First = 0;
--- 42,48 ----
  
  =cut
  
! use vars qw($MsgNum $First $Last $PrevDst $sys_fsync);
  BEGIN {
      $MsgNum = 0;
      $First = 0;
***************
*** 122,127 ****
--- 122,133 ----
  		return -1;
  	    }
  	}
+ 	if (&unixp() && !&no_sync()) {
+ 	    if (fsync(fileno(ART)) < 0) {
+ 		im_err("writing to $file failed ($!).\n");
+ 		return -1;
+ 	    }
+ 	}
  	unless (close(ART)) {
  	    im_err("writing to $file failed ($!).\n");
  	    return -1;
***************
*** 279,284 ****
--- 285,322 ----
  #   return -1 if (-f $file);
  #   return -1 unless (open(MESSAGE, ">$file"));
      return 0;
+ }
+ 
+ sub fsync ($) {
+     my $fno = shift;
+ 
+     unless (defined($sys_fsync)) {
+ 	my $inc = 'syscall.ph';
+ 	my $prefix;
+ 	foreach $prefix (@INC) {
+ 	    if (-f "$prefix/$inc") {
+ 		require "$prefix/$inc";
+ 		$sys_fsync = &SYS_fsync;
+ 		last;
+ 	    }
+ 	}
+ 	unless ($sys_fsync) {
+ #	    im_warn ("syscall.ph not found. using syscall.h instead.\n");
+ 	    if (open(SYSCALL_H, '</usr/include/sys/syscall.h')) {
+ 		while (<SYSCALL_H>) {
+ 		    if (/^\s*#\s*define\s+SYS_fsync\s+(\d+)/) {
+ 			$sys_fsync = $1;
+ 			last;
+ 		    }
+ 		}
+ 		close(SYSCALL_H);
+ 	    }
+ 	}
+ 	unless ($sys_fsync) {
+ 	    im_die("Can't locate syscall.ph in @INC (did you run h2ph?).\n");
+ 	}
+     }
+     return syscall($sys_fsync, $fno);
  }
  
  1;
Only in .: MsgStore.pm.in.orig




Mew-dist メーリングリストの案内