1 : /*
2 : * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 : * Use of this source code is governed by a BSD-style license that can be
4 : * found in the LICENSE file.
5 : */
6 :
7 : /*
8 : * NaCl Service Runtime. I/O Descriptor quota interface.
9 : */
10 :
11 : #include <stdlib.h>
12 : #include <string.h>
13 : #include <sys/types.h>
14 :
15 : #include "native_client/src/include/portability.h"
16 : #include "native_client/src/include/nacl_platform.h"
17 :
18 : #include "native_client/src/shared/platform/nacl_log.h"
19 :
20 : #include "native_client/src/trusted/desc/nacl_desc_quota_interface.h"
21 :
22 : #include "native_client/src/trusted/nacl_base/nacl_refcount.h"
23 :
24 1 : int NaClDescQuotaInterfaceCtor(struct NaClDescQuotaInterface *self) {
25 1 : if (!NaClRefCountCtor(&self->base)) {
26 0 : return 0;
27 : }
28 1 : self->base.vtbl = (struct NaClRefCountVtbl *) (&kNaClDescQuotaInterfaceVtbl);
29 1 : return 1;
30 1 : }
31 :
32 1 : static void NaClDescQuotaInterfaceDtor(struct NaClRefCount *nrcp) {
33 1 : nrcp->vtbl = &kNaClRefCountVtbl;
34 1 : (*nrcp->vtbl->Dtor)(nrcp);
35 1 : }
36 :
37 : struct NaClDescQuotaInterface *NaClDescQuotaInterfaceRef(
38 1 : struct NaClDescQuotaInterface *ndqip) {
39 1 : return (struct NaClDescQuotaInterface *) NaClRefCountRef(&ndqip->base);
40 1 : }
41 :
42 0 : void NaClDescQuotaInterfaceUnref(struct NaClDescQuotaInterface *ndqip) {
43 0 : NaClRefCountUnref(&ndqip->base);
44 0 : }
45 :
46 1 : void NaClDescQuotaInterfaceSafeUnref(struct NaClDescQuotaInterface *ndqip) {
47 1 : if (NULL != ndqip) {
48 1 : NaClRefCountUnref(&ndqip->base);
49 : }
50 1 : }
51 :
52 : int64_t NaClDescQuotaInterfaceWriteRequestNotImplemented(
53 : struct NaClDescQuotaInterface *vself,
54 : uint8_t const *file_id,
55 : int64_t offset,
56 0 : int64_t length) {
57 : UNREFERENCED_PARAMETER(vself);
58 : UNREFERENCED_PARAMETER(file_id);
59 : UNREFERENCED_PARAMETER(offset);
60 : UNREFERENCED_PARAMETER(length);
61 0 : NaClLog(LOG_FATAL, "NaClDescQuotaInterface: WriteRequest not implemented.");
62 0 : return 0;
63 0 : }
64 :
65 : int64_t NaClDescQuotaInterfaceFtruncateRequestNotImplemented(
66 : struct NaClDescQuotaInterface *vself,
67 : uint8_t const *file_id,
68 0 : int64_t length) {
69 : UNREFERENCED_PARAMETER(vself);
70 : UNREFERENCED_PARAMETER(file_id);
71 : UNREFERENCED_PARAMETER(length);
72 : NaClLog(LOG_FATAL,
73 0 : "NaClDescQuotaInterface: FtruncateRequest not implemented.");
74 0 : return 0;
75 0 : }
76 :
77 : struct NaClDescQuotaInterfaceVtbl const kNaClDescQuotaInterfaceVtbl = {
78 : {
79 : NaClDescQuotaInterfaceDtor,
80 : },
81 : NaClDescQuotaInterfaceWriteRequestNotImplemented,
82 : NaClDescQuotaInterfaceFtruncateRequestNotImplemented,
83 : };
|