Login

Subversion Repositories NedoOS

Rev

Rev 1229 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/* device_info.c - Collect device information for mkfs.fat

   Copyright (C) 2015 Andreas Bombe <aeb@debian.org>
   Copyright (C) 2018 Pali Roh├бr <pali.rohar@gmail.com>

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/



#include <limits.h>
#include <stdint.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
//#include <sys/ioctl.h>

#include <unistd.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>

#include "device_info.h"


static const struct device_info device_info_clueless = {
    .type         = TYPE_UNKNOWN,
    .partition    = -1,
    .has_children = -1,
    .geom_heads   = -1,
    .geom_sectors = -1,
    .geom_start   = -1,
    .geom_size    = -1,
    .sector_size  = -1,
    .size         = -1,
};


int device_info_verbose;




int get_device_info(int fd, struct device_info *info)
{
    struct stat stat;
    int ret;

    *info = device_info_clueless;

    ret = fstat(fd, &stat);
    if (ret < 0) {
        perror("fstat on target failed");
        return -1;
    }

//    if (S_ISREG(stat.st_mode)) {
        /* there is nothing more to discover for an image file */
        info->type = TYPE_FILE;
        info->partition = 0;
        info->size = stat.st_size;
        return 0;
//    }

}


int is_device_mounted(const char *path)
{
    (void)path; /* prevent unused parameter warning */
    return 0;
}