summaryrefslogtreecommitdiffstats
path: root/sbin/mount_ntfs
diff options
context:
space:
mode:
authorsemenu <semenu@FreeBSD.org>2001-09-08 23:03:52 +0000
committersemenu <semenu@FreeBSD.org>2001-09-08 23:03:52 +0000
commit8c98d68610fb0ec072a45372df6fae9ec3afd215 (patch)
tree19a136464adf6bfe402fbab8c1d2c88463c6d7e7 /sbin/mount_ntfs
parent22c38894cbd19ca224d48e51045206a9406b5c0f (diff)
downloadFreeBSD-src-8c98d68610fb0ec072a45372df6fae9ec3afd215.zip
FreeBSD-src-8c98d68610fb0ec072a45372df6fae9ec3afd215.tar.gz
Stole unicode translation table from mount_msdos. Add kernel code
to support this translation. MFC after: 2 weeks
Diffstat (limited to 'sbin/mount_ntfs')
-rw-r--r--sbin/mount_ntfs/Makefile2
-rw-r--r--sbin/mount_ntfs/mount_ntfs.86
-rw-r--r--sbin/mount_ntfs/mount_ntfs.c79
3 files changed, 85 insertions, 2 deletions
diff --git a/sbin/mount_ntfs/Makefile b/sbin/mount_ntfs/Makefile
index 042c5e5..369d255 100644
--- a/sbin/mount_ntfs/Makefile
+++ b/sbin/mount_ntfs/Makefile
@@ -5,6 +5,8 @@
PROG= mount_ntfs
SRCS= mount_ntfs.c getmntopts.c
MAN= mount_ntfs.8
+DPADD= ${LIBUTIL}
+LDADD= -lutil
MOUNT= ${.CURDIR}/../mount
CFLAGS+=-I${MOUNT}
diff --git a/sbin/mount_ntfs/mount_ntfs.8 b/sbin/mount_ntfs/mount_ntfs.8
index 265e966..0ae53d2 100644
--- a/sbin/mount_ntfs/mount_ntfs.8
+++ b/sbin/mount_ntfs/mount_ntfs.8
@@ -43,6 +43,7 @@
.Op Fl u Ar uid
.Op Fl g Ar gid
.Op Fl m Ar mask
+.Op Fl W Ar u2wtable
.Pa special
.Pa node
.Sh DESCRIPTION
@@ -80,6 +81,11 @@ on which the file system is being mounted.
.It Fl m Ar mask
Specify the maximum file permissions for files
in the file system.
+.It Fl W Ar u2wtable
+Specify unix to unicode translation table. This option is
+completly stolen from
+.Xr mount_msdos 8
+so refer its manpage.
.El
.Sh FEATURES
NTFS file attributes are accessed in following way:
diff --git a/sbin/mount_ntfs/mount_ntfs.c b/sbin/mount_ntfs/mount_ntfs.c
index b01e422..81e1376 100644
--- a/sbin/mount_ntfs/mount_ntfs.c
+++ b/sbin/mount_ntfs/mount_ntfs.c
@@ -47,6 +47,7 @@
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
+#include <libutil.h>
#include "mntopts.h"
@@ -60,6 +61,8 @@ static uid_t a_uid __P((char *));
static mode_t a_mask __P((char *));
static void usage __P((void)) __dead2;
+static void load_u2wtable __P((struct ntfs_args *, char *));
+
int
main(argc, argv)
int argc;
@@ -78,7 +81,7 @@ main(argc, argv)
mntflags = set_gid = set_uid = set_mask = 0;
(void)memset(&args, '\0', sizeof(args));
- while ((c = getopt(argc, argv, "aiu:g:m:o:")) != -1) {
+ while ((c = getopt(argc, argv, "aiu:g:m:o:W:")) != -1) {
switch (c) {
case 'u':
args.uid = a_uid(optarg);
@@ -101,6 +104,10 @@ main(argc, argv)
case 'o':
getmntopts(optarg, mopts, &mntflags, 0);
break;
+ case 'W':
+ load_u2wtable(&args, optarg);
+ args.flag |= NTFSMNT_U2WTABLE;
+ break;
case '?':
default:
usage();
@@ -233,6 +240,74 @@ a_mask(s)
void
usage()
{
- fprintf(stderr, "usage: mount_ntfs [-a] [-i] [-u user] [-g group] [-m mask] bdev dir\n");
+ fprintf(stderr, "usage: mount_ntfs [-a] [-i] [-u user] [-g group] [-m mask] [-W u2wtable] bdev dir\n");
exit(EX_USAGE);
}
+
+void
+load_u2wtable (pargs, name)
+ struct ntfs_args *pargs;
+ char *name;
+{
+ FILE *f;
+ int i, j, code[8];
+ size_t line = 0;
+ char buf[128];
+ char *fn, *s, *p;
+
+ if (*name == '/')
+ fn = name;
+ else {
+ snprintf(buf, sizeof(buf), "/usr/libdata/msdosfs/%s", name);
+ buf[127] = '\0';
+ fn = buf;
+ }
+ if ((f = fopen(fn, "r")) == NULL)
+ err(EX_NOINPUT, "%s", fn);
+ p = NULL;
+ for (i = 0; i < 16; i++) {
+ do {
+ if (p != NULL) free(p);
+ if ((p = s = fparseln(f, NULL, &line, NULL, 0)) == NULL)
+ errx(EX_DATAERR, "can't read u2w table row %d near line %d", i, line);
+ while (isspace((unsigned char)*s))
+ s++;
+ } while (*s == '\0');
+ if (sscanf(s, "%i%i%i%i%i%i%i%i",
+code, code + 1, code + 2, code + 3, code + 4, code + 5, code + 6, code + 7) != 8)
+ errx(EX_DATAERR, "u2w table: missing item(s) in row %d, line %d", i, line);
+ for (j = 0; j < 8; j++)
+ pargs->u2w[i * 8 + j] = code[j];
+ }
+ for (i = 0; i < 16; i++) {
+ do {
+ free(p);
+ if ((p = s = fparseln(f, NULL, &line, NULL, 0)) == NULL)
+ errx(EX_DATAERR, "can't read d2u table row %d near line %d", i, line);
+ while (isspace((unsigned char)*s))
+ s++;
+ } while (*s == '\0');
+ if (sscanf(s, "%i%i%i%i%i%i%i%i",
+code, code + 1, code + 2, code + 3, code + 4, code + 5, code + 6, code + 7) != 8)
+ errx(EX_DATAERR, "d2u table: missing item(s) in row %d, line %d", i, line);
+ for (j = 0; j < 8; j++)
+ /* pargs->d2u[i * 8 + j] = code[j] */;
+ }
+ for (i = 0; i < 16; i++) {
+ do {
+ free(p);
+ if ((p = s = fparseln(f, NULL, &line, NULL, 0)) == NULL)
+ errx(EX_DATAERR, "can't read u2d table row %d near line %d", i, line);
+ while (isspace((unsigned char)*s))
+ s++;
+ } while (*s == '\0');
+ if (sscanf(s, "%i%i%i%i%i%i%i%i",
+code, code + 1, code + 2, code + 3, code + 4, code + 5, code + 6, code + 7) != 8)
+ errx(EX_DATAERR, "u2d table: missing item(s) in row %d, line %d", i, line);
+ for (j = 0; j < 8; j++)
+ /* pargs->u2d[i * 8 + j] = code[j] */;
+ }
+ free(p);
+ fclose(f);
+}
+
OpenPOWER on IntegriCloud