blob: b219d4e658c3e56e797310f16dc5dda66745cf83 [file] [log] [blame]
bigbiff bigbiff9c754052013-01-09 09:09:08 -05001/*
2 main.c (20.01.11)
3 Prints or changes exFAT volume label.
4
bigbiff bigbiff61cdc022013-08-08 08:35:06 -04005 Free exFAT implementation.
Matt Mower09ef1e42015-12-13 11:29:45 -06006 Copyright (C) 2011-2015 Andrew Nayenko
bigbiff bigbiff9c754052013-01-09 09:09:08 -05007
bigbiff bigbiff61cdc022013-08-08 08:35:06 -04008 This program is free software; you can redistribute it and/or modify
bigbiff bigbiff9c754052013-01-09 09:09:08 -05009 it under the terms of the GNU General Public License as published by
bigbiff bigbiff61cdc022013-08-08 08:35:06 -040010 the Free Software Foundation, either version 2 of the License, or
bigbiff bigbiff9c754052013-01-09 09:09:08 -050011 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
bigbiff bigbiff61cdc022013-08-08 08:35:06 -040018 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bigbiff bigbiff9c754052013-01-09 09:09:08 -050021*/
22
Matt Mower09ef1e42015-12-13 11:29:45 -060023#include <exfat.h>
bigbiff bigbiff9c754052013-01-09 09:09:08 -050024#include <stdio.h>
25#include <string.h>
bigbiff bigbiff9c754052013-01-09 09:09:08 -050026
27int main(int argc, char* argv[])
28{
29 char** pp;
30 struct exfat ef;
31 int rc = 0;
32
33 for (pp = argv + 1; *pp; pp++)
bigbiff bigbiff004e2df2013-07-03 14:52:12 -040034 if (strcmp(*pp, "-V") == 0)
bigbiff bigbiff9c754052013-01-09 09:09:08 -050035 {
Matt Mower09ef1e42015-12-13 11:29:45 -060036 printf("exfatlabel %s\n", VERSION);
37 puts("Copyright (C) 2011-2015 Andrew Nayenko");
bigbiff bigbiff9c754052013-01-09 09:09:08 -050038 return 0;
39 }
40
41 if (argc != 2 && argc != 3)
42 {
bigbiff bigbiff004e2df2013-07-03 14:52:12 -040043 fprintf(stderr, "Usage: %s [-V] <device> [label]\n", argv[0]);
bigbiff bigbiff9c754052013-01-09 09:09:08 -050044 return 1;
45 }
46
47 if (argv[2])
48 {
49 if (exfat_mount(&ef, argv[1], "") != 0)
50 return 1;
51 rc = (exfat_set_label(&ef, argv[2]) != 0);
52 }
53 else
54 {
55 if (exfat_mount(&ef, argv[1], "ro") != 0)
56 return 1;
57 puts(exfat_get_label(&ef));
58 }
59
60 exfat_unmount(&ef);
61 return rc;
62}