Symbolic link in Log structured file system - operating-system

I am doing a project on Log structure File system,I am mid way doing the project,Have created the inodes for the normal file and directory ,now i want to work on symbolic link.
Here is the structure for my inode.
int8_t is_active;
/* inode no. of the file */
uint16_t inode_number;
/* the most up-to-date version id */
uint8_t latest_version_id;
/* Details about the direct block */
BlockInfo direct_block[4];
/* Details about the indirect block */
BlockInfo indirect_block;
/* The type, permissions, etc. */
unsigned long inode_mode;
/* The user id */
//unsigned short uid;
/* The group id */
//unsigned short gid;
/* The number of links to the inode */
unsigned short number_of_links;
/* The size of the file, in bytes.
* If it is a directory file, this will contain the number of
* immediate children in the directory.
*
* If it is a regular file, it will contain the actual file size*/
unsigned long int file_size;
/* The number of blocks used by the inode */
unsigned long number_of_blocks;
/* The creation time of the file */
struct timeval creation_time;
/* The modification time of the file */
struct timeval modification_time;
struct timeval access_time;
Can Anybody help me in going about creating symbolic links.

A symlink is a regular file with the pathname to the target contained in it. Use a mode bit to cause the filesystem code to read the link and do the redirect on open, create, unlink, etc.

Related

Fix explicit link warning

I have rather big project with doxygen and some files marked as #internal, some not.
When I build internal documentation no warnings are generated, but when I try to build not internal I got some warnings:
some_header.h:61 warning: explicit link request to 'MyStruct' could not be resolved
some_header.h:58 warning: explicit link request to 'AnotherMyStruct' could not be resolved
some_header.h:58 warning: explicit link request to 'AnotherMyStruct' could not be resolved
some_header.h:61 warning: explicit link request to 'MyStruct' could not be resolved
But some_header.h is internal. As an idea I think that it is included in non internal file, but it is wrong. I deleted all includes of the header, but the message doesn't gone.
How can I fix this warning?
P.S. duplicates of warning mean that there 2 places with error?
$doxygen -x
FULL_PATH_NAMES = NO
JAVADOC_AUTOBRIEF = YES
OPTIMIZE_OUTPUT_FOR_C = YES
EXTRACT_STATIC = YES
QUIET = YES
WARN_IF_UNDOCUMENTED = NO
WARN_FORMAT =
FILE_PATTERNS = *.c *.h
RECURSIVE = YES
EXAMPLE_PATTERNS =
SOURCE_BROWSER = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
ALPHABETICAL_INDEX = NO
HTML_OUTPUT =
SEARCHENGINE = NO
GENERATE_LATEX = NO
LATEX_OUTPUT =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
RTF_OUTPUT =
MAN_LINKS = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
PREDEFINED = (a lot of)
TEMPLATE_RELATIONS = YES
Simple example to reproduce problem:
flags.h:
/**
* #file
* #brief Public Flags.
*/
#ifndef PUBLIC_FLAGS_H
#define PUBLIC_FLAGS_H
#pragma once
/**
* Public flags
*/
typedef enum {
FLAG_READ = 1, /**< reading allowed */
FLAG_WRITE = 2, /**< writing allowed */
} PublicFlags;
#endif /* PUBLIC_FLAGS_H */
info.h
/**
* #file
* #brief Public header.
*/
#ifndef TEST_PUBLIC_H
#define TEST_PUBLIC_H
#pragma once
#include "flags.h"
/**
* Defines public enum.
*/
typedef enum EPublicEnum {
TestEnum1, /**< enum 1 */
TestEnum2, /**< enum 2 */
TestEnum3 /**< enum 3 */
} PublicEnum;
/**
* Defines public struct.
*/
typedef struct SPublicStruct {
PublicEnum state; /**< state (see #PublicEnum). */
unsigned flags; /**< set of flags see #PublicFlags.*/
} PublicStruct;
#endif /* TEST_PUBLIC_H */
internal_enums.h
/**
* #internal
* #file
* #brief Internal Enums
*/
#ifndef INTERNAL_ENUMS_H
#define INTERNAL_ENUMS_H
#pragma once
#include "flags.h"
#include "info.h"
/**
* Possible types:
*
* TypeMisc - Misc type.
* TypeIo - IO type.
*/
typedef enum {
TypeMisc,
TypeIo,
} InternalEnumType;
/** Owner type. */
typedef enum {
Kernel = 0, /**< kernel. */
User = 1 /**< user. */
} InternalEnumOwner;
#endif /* INTERNAL_ENUMS_H */
internal_struct.h
/**
* #internal
* #file
* #brief Internal structures.
*/
#ifndef INTERNAL_STRUCT_H
#define INTERNAL_STRUCT_H
#include "internal_enums.h"
typedef struct SInternalStruct {
rtl_uint8_t owner : 1; /**< values from #InternalEnumOwner */
rtl_uint8_t type : 1; /**< values from #InternalEnumType */
} InternalStruct;
#endif /* INTERNAL_STRUCT_H */
problem:
warning: explicit link request to 'InternalEnumOwner' could not be resolved
warning: explicit link request to 'InternalEnumType' could not be resolved
There is a misunderstanding about what the \internal command does in doxygen does, from the documentation:
24.29 \internal
This command starts a documentation fragment that is meant for internal use only. The fragment naturally ends
at the end of the comment block. You can also force the internal section to end earlier by using the \endinternal
command.
If the \internal command is put inside a section (see for example \section) all subsections after the command
are considered to be internal as well. Only a new section at the same level will end the fragment that is considered
internal.
You can use INTERNAL_DOCS in the configuration file to show (YES) or hide (NO) the internal documentation.
This means that the comment between the \internal and the \endinternal (or end of the comment block) is not part of the documentation (unless the setting INTERNAL_DOCS is set), in this case it is just about the parts like:
/**
* #internal
* #file
* #brief Internal structures.
*/
so the \internal command here has not the desired effect and should be removed.
What actually is desired (when I understand it correctly) is that the entire file isn't used. This can be accomplished by means of either:
add the setting EXCLUDE_PATTERNS = internal*
or
explicitly listing all files and directories that should be used, her this is by adding the setting INPUT = info.h flags.h
In case only part of a file, i.e documentation and code, should not enter the documentation one can use the commands \cond ... \endcond. For disabling just part of a documentation block the commands \if .. \endif are useful. Both sets of commands go together with the setting ENABLED_SECTIONS.
For a description of the mentioned command see the doxygen manual (e.g. at https://www.doxygen.nl/manual/index.html and more specifically the chapters: https://www.doxygen.nl/manual/config.html and https://www.doxygen.nl/manual/commands.html)

Static function in Cpp file Doxygen

I generate the my source code with Doxygen,
Doxygen generate void and another fucntion but it didnt generate static function although EXTRACT_STATIC is YES.
I am currently using version of the Doxygen 1.8.19and
I added top of the example.cpp file /** #file example.cpp */
I am using .c and .cpp file together. In the example.cpp file I have:
/**
*#brief ..
*#param size The application receives in this parameter the size of the required memory block.
*#retval The application must return a pointer to the allocated and zeroed-out memory block.
*/
static void* CheckVal (unsigned int size)
{
void* result = malloc (size);
assert (result != NULL);
memset (result, 0, size);
return result;
}
I couldnt see any function in doxygen index.html . Why this happened?

How come sin_addr is a union if I have never declared it to be?

In socket programming, how come my compiler knows that sin_addr is a union if I have never declared it to be?
server_address.sin_addr.s_addr = INADDR_ANY;
Also, while starting a socket:
struct sockaddr_in server_address;
Is "sockaddr_in" a command that my compllier understand? is it a struct that can be changed?
Would be appreciated if you could explain it in a way that a newbie would understand. I am programming for less than a week.
With a nice compiler, you can jump into the header files in which they are declared.
On my machine in arpa/inet.h(ymmv),
typedef unsigned int __uint32_t;
#ifndef _IN_ADDR_T
#define _IN_ADDR_T
#include <machine/types.h> /* __uint32_t */
typedef __uint32_t in_addr_t; /* base type for internet address */
#endif /* _IN_ADDR_T */
/*
* Internet address (a structure for historical reasons)
*/
struct in_addr {
in_addr_t s_addr;
};
/*
* Definitions of bits in internet address integers.
* On subnets, the decomposition of addresses to host and net parts
* is done according to subnet mask, not the masks here.
*/
#define INADDR_ANY (u_int32_t)0x00000000
/*
* Socket address, internet style.
*/
struct sockaddr_in {
__uint8_t sin_len;
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
Do you read from where it comes?

Doxygen: How do I link to a static variable?

I'm currently generating documentation for a pure C project.
In a file utilities.h file I have this:
/**
* #defgroup LOG_LEVELS Different levels of log file granularity
*
* \addtogroup LOG_LEVELS
* #{
* Each logging routine has a mandatory parameter defining the logging level
* of the current logging function call. Only if that level is less or equal
* to one of those predefined levels by the constants given here, that call
* will actually be logged. These constants are also used to set the current
* logging level in #currentLogPrio .
**/
#define LOGPRIO_ALWAYS 0 /**< always log this, although no error */
#define LOGPRIO_FATAL 0 /**< fatal errors */
#define LOGPRIO_ALERT 100 /**< alerts */
#define LOGPRIO_CRITICAL 200 /**< critical, but not fatal errors */
#define LOGPRIO_ERROR 300 /**< normal errors */
#define LOGPRIO_WARNING 400 /**< warnings */
#define LOGPRIO_NOTICE 500 /**< notices */
#define LOGPRIO_INFO 600 /**< informational texts */
#define LOGPRIO_TRACE 700 /**< tracing */
#define LOGPRIO_DEBUG 800 /**< debugging information */
/** #} **/
In the associated utilities.c file the static variable currentLogPrio is defined:
/**
* #var currentLogPrio
* #brief Current setting of the logging level.
*
* Only if a logging routine was called with its log level parameter set to a
* value less than or equal to the current logging priority the actual call of
* a logging routine will be written to the log.
**/
static logPrio_t currentLogPrio = LOGPRIO_ALWAYS;
Now, when I run doxygen on the complete project, I get the following warning:
...
Preprocessing utilities/logUtilities.c...
Parsing file utilities/logUtilities.c...
Preprocessing utilities/logUtilities.h...
Parsing file utilities/logUtilities.h...
...
Generating code for file utilities/logUtilities.c...
Generating code for file utilities/logUtilities.h...
...
Generating docs for file utilities/logUtilities.h...
Generating call graph for function logErrcode
Generating call graph for function logMsg_alert
Generating call graph for function logMsg_always
Generating caller graph for function logMsg_always
Generating call graph for function logMsg_critical
Generating call graph for function logMsg_debug
Generating caller graph for function logMsg_debug
Generating call graph for function logMsg_error
Generating caller graph for function logMsg_error
Generating call graph for function logMsg_fatal
Generating caller graph for function logMsg_fatal
utilities/logUtilities.h:136: warning: explicit link request to 'currentLogPrio' could not be resolved
Both files are part of the doxygen documentation as you can see from doxygens output and have the #file tag included. I also know that the #var tag for the static variable is not needed, but I get the same errors with or without this tag.
So, how can I link to that static variable?
Best regards and thanks in advance

How to add Doxygen Comments for "C" variables with long type names

I have a code
static const guint8 variable;
when I put a documentation
/**
* \var static const guint8 variable;
* \brief This is a variable
*/
static const guint8 variable;
I do not get any output in the generated documentation. However, when the same thing is done with a simple variable decleration:
/**
* \var int someothervar;
* \brief This is some other variable
*/
int variable;
it does work
is that I am making some mistake in the usage ?
Thanks for any help in advance,
- elechi
For extracting static variables you should set EXTRACT_STATIC to YES.
If the documentation is in front of the variable, you do not need (and should not use) \var
Either set EXTRACT_ALL to YES or add a comment with a #file command in your code to document the file itself.