bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 1 | /* |
| 2 | main.c (20.01.11) |
| 3 | Prints or changes exFAT volume label. |
| 4 | |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 5 | Free exFAT implementation. |
bigbiff | c40c1c5 | 2014-11-01 09:34:57 -0400 | [diff] [blame] | 6 | Copyright (C) 2011-2013 Andrew Nayenko |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 7 | |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 8 | This program is free software; you can redistribute it and/or modify |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 9 | it under the terms of the GNU General Public License as published by |
bigbiff bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 10 | the Free Software Foundation, either version 2 of the License, or |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 11 | (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 bigbiff | 61cdc02 | 2013-08-08 08:35:06 -0400 | [diff] [blame] | 18 | 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 bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | #include <stdio.h> |
| 24 | #include <string.h> |
| 25 | #include <exfat.h> |
| 26 | |
| 27 | int 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 bigbiff | 004e2df | 2013-07-03 14:52:12 -0400 | [diff] [blame] | 34 | if (strcmp(*pp, "-V") == 0) |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 35 | { |
| 36 | printf("exfatlabel %u.%u.%u\n", EXFAT_VERSION_MAJOR, |
| 37 | EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH); |
bigbiff | c40c1c5 | 2014-11-01 09:34:57 -0400 | [diff] [blame] | 38 | puts("Copyright (C) 2011-2013 Andrew Nayenko"); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | if (argc != 2 && argc != 3) |
| 43 | { |
bigbiff bigbiff | 004e2df | 2013-07-03 14:52:12 -0400 | [diff] [blame] | 44 | fprintf(stderr, "Usage: %s [-V] <device> [label]\n", argv[0]); |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 45 | return 1; |
| 46 | } |
| 47 | |
| 48 | if (argv[2]) |
| 49 | { |
| 50 | if (exfat_mount(&ef, argv[1], "") != 0) |
| 51 | return 1; |
| 52 | rc = (exfat_set_label(&ef, argv[2]) != 0); |
| 53 | } |
| 54 | else |
| 55 | { |
| 56 | if (exfat_mount(&ef, argv[1], "ro") != 0) |
| 57 | return 1; |
| 58 | puts(exfat_get_label(&ef)); |
| 59 | } |
| 60 | |
| 61 | exfat_unmount(&ef); |
| 62 | return rc; |
| 63 | } |