Subversion Repositories NedoOS

Rev

Rev 1229 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
1229 lvd 1
/* device_info.c - Collect device information for mkfs.fat
2
 
3
   Copyright (C) 2015 Andreas Bombe <aeb@debian.org>
4
   Copyright (C) 2018 Pali Rohár <pali.rohar@gmail.com>
5
 
6
   This program is free software: you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation, either version 3 of the License, or
9
   (at your option) any later version.
10
 
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
*/
19
 
20
 
21
#include <limits.h>
22
#include <stdint.h>
23
#include <stdbool.h>
24
#include <sys/types.h>
25
#include <sys/stat.h>
1231 lvd 26
//#include <sys/ioctl.h>
1229 lvd 27
 
28
#include <unistd.h>
29
#include <dirent.h>
30
#include <stdio.h>
31
#include <string.h>
32
#include <stdlib.h>
33
#include <errno.h>
34
 
35
#include "device_info.h"
36
 
37
 
38
static const struct device_info device_info_clueless = {
39
    .type         = TYPE_UNKNOWN,
40
    .partition    = -1,
41
    .has_children = -1,
42
    .geom_heads   = -1,
43
    .geom_sectors = -1,
44
    .geom_start   = -1,
45
    .geom_size    = -1,
46
    .sector_size  = -1,
47
    .size         = -1,
48
};
49
 
50
 
51
int device_info_verbose;
52
 
53
 
54
 
55
 
56
int get_device_info(int fd, struct device_info *info)
57
{
58
    struct stat stat;
59
    int ret;
60
 
61
    *info = device_info_clueless;
62
 
63
    ret = fstat(fd, &stat);
64
    if (ret < 0) {
65
        perror("fstat on target failed");
66
        return -1;
67
    }
68
 
69
//    if (S_ISREG(stat.st_mode)) {
70
        /* there is nothing more to discover for an image file */
71
        info->type = TYPE_FILE;
72
        info->partition = 0;
73
        info->size = stat.st_size;
74
        return 0;
75
//    }
76
 
77
}
78
 
79
 
80
int is_device_mounted(const char *path)
81
{
82
    (void)path; /* prevent unused parameter warning */
83
    return 0;
84
}