Deleted Added
full compact
bf.c (98121) bf.c (98841)
1/*
2 * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 *
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 *

--- 4 unchanged lines hidden (view full) ---

13/*
14** This is in transition. Changed from the original bf_torek.c code
15** to use sm_io function calls directly rather than through stdio
16** translation layer. Will be made a built-in file type of libsm
17** next (once safeopen() linkable from libsm).
18*/
19
20#include <sm/gen.h>
1/*
2 * Copyright (c) 1999-2002 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 *
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 *

--- 4 unchanged lines hidden (view full) ---

13/*
14** This is in transition. Changed from the original bf_torek.c code
15** to use sm_io function calls directly rather than through stdio
16** translation layer. Will be made a built-in file type of libsm
17** next (once safeopen() linkable from libsm).
18*/
19
20#include <sm/gen.h>
21SM_RCSID("@(#)$Id: bf.c,v 8.54 2002/04/20 18:03:42 gshapiro Exp $")
21SM_RCSID("@(#)$Id: bf.c,v 8.54.2.2 2002/06/21 19:58:40 gshapiro Exp $")
22
23#include <sys/types.h>
24#include <sys/stat.h>
25#include <sys/uio.h>
26#include <fcntl.h>
27#include <unistd.h>
28#include <stdlib.h>
29#include <string.h>

--- 646 unchanged lines hidden (view full) ---

676
677 /* If already committed, noop */
678 if (bfp->bf_committed)
679 return 0;
680
681 /* Do we need to open a file? */
682 if (!bfp->bf_ondisk)
683 {
22
23#include <sys/types.h>
24#include <sys/stat.h>
25#include <sys/uio.h>
26#include <fcntl.h>
27#include <unistd.h>
28#include <stdlib.h>
29#include <string.h>

--- 646 unchanged lines hidden (view full) ---

676
677 /* If already committed, noop */
678 if (bfp->bf_committed)
679 return 0;
680
681 /* Do we need to open a file? */
682 if (!bfp->bf_ondisk)
683 {
684 int save_errno;
684 MODE_T omask;
685 struct stat st;
686
687 if (tTd(58, 8))
688 {
689 sm_dprintf("bfcommit(%s): to disk\n", bfp->bf_filename);
690 if (tTd(58, 32))
691 sm_dprintf("bfcommit(): filemode %o flags %ld\n",
692 bfp->bf_filemode, bfp->bf_flags);
693 }
694
695 if (stat(bfp->bf_filename, &st) == 0)
696 {
697 errno = EEXIST;
698 return -1;
699 }
700
701 /* Clear umask as bf_filemode are the true perms */
702 omask = umask(0);
685 MODE_T omask;
686 struct stat st;
687
688 if (tTd(58, 8))
689 {
690 sm_dprintf("bfcommit(%s): to disk\n", bfp->bf_filename);
691 if (tTd(58, 32))
692 sm_dprintf("bfcommit(): filemode %o flags %ld\n",
693 bfp->bf_filemode, bfp->bf_flags);
694 }
695
696 if (stat(bfp->bf_filename, &st) == 0)
697 {
698 errno = EEXIST;
699 return -1;
700 }
701
702 /* Clear umask as bf_filemode are the true perms */
703 omask = umask(0);
703 retval = OPEN(bfp->bf_filename, O_RDWR | O_CREAT | O_TRUNC,
704 retval = OPEN(bfp->bf_filename, O_RDWR | O_CREAT | O_EXCL,
704 bfp->bf_filemode, bfp->bf_flags);
705 bfp->bf_filemode, bfp->bf_flags);
706 save_errno = errno;
705 (void) umask(omask);
706
707 /* Couldn't create file: failure */
708 if (retval < 0)
709 {
710 /* errno is set implicitly by open() */
707 (void) umask(omask);
708
709 /* Couldn't create file: failure */
710 if (retval < 0)
711 {
712 /* errno is set implicitly by open() */
713 errno = save_errno;
711 return -1;
712 }
713
714 bfp->bf_disk_fd = retval;
715 bfp->bf_ondisk = true;
716 }
717
718 /* Write out the contents of our buffer, if we have any */

--- 137 unchanged lines hidden ---
714 return -1;
715 }
716
717 bfp->bf_disk_fd = retval;
718 bfp->bf_ondisk = true;
719 }
720
721 /* Write out the contents of our buffer, if we have any */

--- 137 unchanged lines hidden ---