source: rtems/cpukit/libfs/src/dosfs/msdos_mknod.c @ e197621

4.104.114.84.9
Last change on this file since e197621 was e197621, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 29, 2006 at 7:38:08 PM

2006-08-29 Joel Sherrill <joel@…>

  • libfs/src/dosfs/fat.h, libfs/src/dosfs/msdos.h, libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_eval.c, libfs/src/dosfs/msdos_file.c, libfs/src/dosfs/msdos_free.c, libfs/src/dosfs/msdos_fsunmount.c, libfs/src/dosfs/msdos_init.c, libfs/src/dosfs/msdos_misc.c, libfs/src/dosfs/msdos_mknod.c, libfs/src/imfs/imfs_debug.c: Remove warnings.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  Routine for node creation in MSDOS filesystem.
3 *
4 *  Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
5 *  Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  @(#) $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <sys/types.h>
19#include <sys/stat.h>
20#include <fcntl.h>
21#include <unistd.h>
22#include <errno.h>
23#include <stdlib.h>
24#include <rtems.h>
25
26#include <rtems/libio_.h>
27
28#include "fat.h"
29#include "fat_fat_operations.h"
30#include "fat_file.h"
31
32#include "msdos.h"
33
34/* msdos_mknod --
35 *     The following function checks spelling and formats name for a new node,
36 *     determines type of the node to be created and creates it.
37 *
38 * PARAMETERS:
39 *     token   - non-formatted name of a new node
40 *     mode    - node type
41 *     dev     - dev
42 *     pathloc - parent directory description
43 *
44 * RETURNS:
45 *     RC_OK on succes, or -1 if error occured and set errno
46 *
47 */
48int msdos_mknod(
49    const char                        *token,
50    mode_t                             mode,
51    dev_t                              dev,
52    rtems_filesystem_location_info_t  *pathloc
53)
54{
55    int                  rc = RC_OK;
56    rtems_status_code    sc = RTEMS_SUCCESSFUL;
57    msdos_fs_info_t     *fs_info = pathloc->mt_entry->fs_info;
58    msdos_token_types_t  type = 0;
59    char                 new_name[ MSDOS_NAME_MAX + 1 ];
60    int                  len;
61
62    /* check spelling and format new node name */
63    msdos_get_token(token, new_name, &len);
64
65    /*
66     *  Figure out what type of msdos node this is.
67     */
68    if (S_ISDIR(mode))
69    {
70       type = MSDOS_DIRECTORY;
71    }
72    else if (S_ISREG(mode))
73    {
74        type = MSDOS_REGULAR_FILE;
75    }
76    else
77        set_errno_and_return_minus_one(EINVAL);
78
79    sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
80                                MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
81    if (sc != RTEMS_SUCCESSFUL)
82        set_errno_and_return_minus_one(EIO);
83
84    /* Create an MSDOS node */
85    rc = msdos_creat_node(pathloc, type, new_name, mode, NULL);
86
87    rtems_semaphore_release(fs_info->vol_sema);
88    return rc;
89}
Note: See TracBrowser for help on using the repository browser.