revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / nonvolatile / nvdisk / meminfonvd.c
blobdbcb7d80b9a5d6e888624c03f9399d5fd0343ad8
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*****************************************************************************
11 NAME */
13 #include "nvdisk_intern.h"
14 #include <dos/dos.h>
15 #include <proto/dos.h>
16 #include <libraries/nonvolatile.h>
19 AROS_LH1(BOOL, MemInfoNVD,
21 /* SYNOPSIS */
23 AROS_LHA(struct NVInfo *, nvInfo, A0),
25 /* LOCATION */
27 struct Library *, nvdBase, 8, NVDisk)
29 /* FUNCTION
31 Return the information associated with the nonvolatile memory.
33 INPUTS
35 nvInfo -- information structure to be filled by this function
37 RESULT
39 The 'nvInfo' structure will be filled with the appropriate values. In
40 case of failure, NULL will be returned.
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 INTERNALS
52 3 blocks of free space are not reported as free, as it may be strange
53 for a user that queries the available storage memory, finds out that
54 free memory exists but still gets errors when using StoreNV() as the
55 memory was used for directory purposes.
57 HISTORY
59 November 2000, SDuvan -- implemented
61 ******************************************************************************/
64 AROS_LIBFUNC_INIT
66 struct InfoData info;
68 if(Info(GPB(nvdBase)->nvd_location, &info))
70 nvInfo->nvi_MaxStorage = info.id_NumBlocks*info.id_BytesPerBlock;
72 /* 3 blocks are subtracted at it may be the case a new application wants
73 to store a new item. Then the 'appName' directory will take one block,
74 the new file will take at least one block and possibly a new directory
75 block may need to be created containing the 'appName' directory */
77 if(info.id_NumBlocks < 3)
78 nvInfo->nvi_FreeStorage = 0;
79 else
81 nvInfo->nvi_FreeStorage =
82 (info.id_NumBlocks - info.id_NumBlocksUsed - 3)*info.id_BytesPerBlock;
85 else
86 return FALSE;
88 return TRUE;
90 AROS_LIBFUNC_EXIT
91 } /* MemInfo */