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

4.104.114.84.95
Last change on this file since a72c454 was a72c454, checked in by Ralf Corsepius <ralf.corsepius@…>, on 08/05/05 at 10:38:05

Introduce msdos_status_t.

  • 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 */
48msdos_status_t
49msdos_mknod(
50    const char                        *token,
51    mode_t                             mode,
52    dev_t                              dev,
53    rtems_filesystem_location_info_t  *pathloc
54    )
55{
56    msdos_status_t       rc = RC_OK;
57    rtems_status_code    sc = RTEMS_SUCCESSFUL;
58    msdos_fs_info_t     *fs_info = pathloc->mt_entry->fs_info;
59    msdos_token_types_t  type = 0;
60    char                 new_name[ MSDOS_NAME_MAX + 1 ];
61    int                  len;
62
63    /* check spelling and format new node name */
64    msdos_get_token(token, new_name, &len);
65
66    /*
67     *  Figure out what type of msdos node this is.
68     */
69    if (S_ISDIR(mode))
70    {
71       type = MSDOS_DIRECTORY;
72    }
73    else if (S_ISREG(mode))
74    {
75        type = MSDOS_REGULAR_FILE;
76    }
77    else
78        set_errno_and_return_minus_one(EINVAL);
79
80    sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
81                                MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
82    if (sc != RTEMS_SUCCESSFUL)
83        set_errno_and_return_minus_one(EIO);
84
85    /* Create an MSDOS node */
86    rc = msdos_creat_node(pathloc, type, new_name, mode, NULL);
87
88    rtems_semaphore_release(fs_info->vol_sema);
89    return rc;
90}
Note: See TracBrowser for help on using the repository browser.