Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:16

0001 /**
0002  * @file
0003  *
0004  * @ingroup libfs_msdos MSDOS FileSystem
0005  *
0006  * @brief Routine for Node Creation in MSDOS Filesystem
0007  */
0008 
0009 /*
0010  *  Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
0011  *  Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
0012  *
0013  *  The license and distribution terms for this file may be
0014  *  found in the file LICENSE in this distribution or at
0015  *  http://www.rtems.org/license/LICENSE.
0016  */
0017 
0018 #ifdef HAVE_CONFIG_H
0019 #include "config.h"
0020 #endif
0021 
0022 #include <sys/types.h>
0023 #include <sys/stat.h>
0024 #include <fcntl.h>
0025 #include <unistd.h>
0026 #include <errno.h>
0027 #include <stdlib.h>
0028 #include <rtems.h>
0029 
0030 #include <rtems/libio_.h>
0031 
0032 #include "fat.h"
0033 #include "fat_fat_operations.h"
0034 #include "fat_file.h"
0035 
0036 #include "msdos.h"
0037 
0038 int msdos_mknod(
0039     const rtems_filesystem_location_info_t *parentloc,
0040     const char *name,
0041     size_t namelen,
0042     mode_t mode,
0043     dev_t dev
0044 )
0045 {
0046     int                  rc = RC_OK;
0047     fat_file_type_t      type = FAT_DIRECTORY;
0048 
0049     /*
0050      *  Figure out what type of msdos node this is.
0051      */
0052     if (S_ISDIR(mode))
0053     {
0054        type = FAT_DIRECTORY;
0055     }
0056     else if (S_ISREG(mode))
0057     {
0058         type = FAT_FILE;
0059     }
0060     else
0061         rtems_set_errno_and_return_minus_one(EINVAL);
0062 
0063     /* Create an MSDOS node */
0064     rc = msdos_creat_node(parentloc, type, name, namelen, mode, NULL);
0065 
0066     return rc;
0067 }