summaryrefslogtreecommitdiff
path: root/libpager/mark-error.c
blob: 1463035c0006bdeab65c3f1a07c0530ff5b4b9f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* Recording errors for pager library
   Copyright (C) 1994 Free Software Foundation

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2, or (at
   your option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */


/* Some error has happened indicating that the page cannot be written. 
   (Usually this is ENOSPC or EDQOUT.)  On the next pagein which
   requests write access, return the error to the kernel.  (This is 
   screwy because of the rules associated with m_o_lock_request.) */
void
mark_next_request_error(struct pager *p,
			int offset,
			int length,
			error_t error)
{
  int page_error;
  char *p;

  offset /= __vm_page_size;
  length /= __vm_page_size;
  
  switch (error)
    {
    case 0:
      page_error = PAGE_NOERR;
      break;
    case ENOSPC:
      page_error = PAGE_ENOSPC;
      break;
    case EIO:
      page_error = PAGE_EIO;
      break;
    case EDQUOT:
      page_error = PAGE_EDQUOT;
      break;
    default:
      panic ("mark_object_error");
      break;
    }
  
  for (p = p->pagemap; p < p->pagemap + length; p++)
    *p = SET_PM_NEXTERROR (*p, page_error);
}

/* We are returning a pager error to the kernel.  Write down
   in the pager what that error was so that the exception handling
   routines can find out.  (This is only necessary because the
   XP interface is not completely implemented in the kernel.) */
void
mark_object_error(struct pager *p,
		  int offset,
		  int length,
		  error_t error)
{
  int page_error = 0;
  char *p;

  offset /= __vm_page_size;
  length /= __vm_page_size;
  
  switch (error)
    {
    case 0:
      page_error = PAGE_NOERR;
      break;
    case ENOSPC:
      page_error = PAGE_ENOSPC;
      break;
    case EIO:
      page_error = PAGE_EIO;
      break;
    case EDQUOT:
      page_error = PAGE_EDQUOT;
      break;
    default:
      panic ("mark_object_error");
      break;
    }
  
  for (p = p->pagemap; p < p->pagemap + length; p++)
    *p = SET_PM_ERROR (*p, page_error);
}