summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix/pvfs_fileinfo.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-25 05:27:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:04:39 -0500
commit1be85de5884d107f89eaf4221f225c9ec468365e (patch)
tree27b97c75724f2bb6e37e4ae1a4b44f20b2cc4a86 /source4/ntvfs/posix/pvfs_fileinfo.c
parent3918ae351db67dd77a393b48e59a487e29febbd9 (diff)
downloadsamba-1be85de5884d107f89eaf4221f225c9ec468365e.tar.gz
samba-1be85de5884d107f89eaf4221f225c9ec468365e.tar.bz2
samba-1be85de5884d107f89eaf4221f225c9ec468365e.zip
r3193: improved the initial permissions choice for file create, based upon dos attribute
(This used to be commit f6fb1e3493a2a0734747f769cd1013215d967cde)
Diffstat (limited to 'source4/ntvfs/posix/pvfs_fileinfo.c')
-rw-r--r--source4/ntvfs/posix/pvfs_fileinfo.c86
1 files changed, 34 insertions, 52 deletions
diff --git a/source4/ntvfs/posix/pvfs_fileinfo.c b/source4/ntvfs/posix/pvfs_fileinfo.c
index 77eb10422d..4fa2c1601b 100644
--- a/source4/ntvfs/posix/pvfs_fileinfo.c
+++ b/source4/ntvfs/posix/pvfs_fileinfo.c
@@ -35,58 +35,6 @@
#define UNIX_TYPE_UNKNOWN 0xFFFFFFFF
-/*
- Return the major devicenumber for UNIX extensions.
-*/
-static uint32_t unix_dev_major(dev_t dev)
-{
-#if defined(HAVE_DEVICE_MAJOR_FN)
- return (uint32)major(dev);
-#else
- return (uint32)(dev >> 8);
-#endif
-}
-
-/*
- Return the minor devicenumber for UNIX extensions.
-*/
-static uint32_t unix_dev_minor(dev_t dev)
-{
-#if defined(HAVE_DEVICE_MINOR_FN)
- return (uint32)minor(dev);
-#else
- return (uint32)(dev & 0xff);
-#endif
-}
-
-/*
- Return the filetype for UNIX extensions
-*/
-static uint32_t unix_filetype(mode_t mode)
-{
- if (S_ISREG(mode)) return UNIX_TYPE_FILE;
- if (S_ISDIR(mode)) return UNIX_TYPE_DIR;
-#ifdef S_ISLNK
- if (S_ISLNK(mode)) return UNIX_TYPE_SYMLINK;
-#endif
-#ifdef S_ISCHR
- if (S_ISCHR(mode)) return UNIX_TYPE_CHARDEV;
-#endif
-#ifdef S_ISBLK
- if (S_ISBLK(mode)) return UNIX_TYPE_BLKDEV;
-#endif
-#ifdef S_ISFIFO
- if (S_ISFIFO(mode)) return UNIX_TYPE_FIFO;
-#endif
-#ifdef S_ISSOCK
- if (S_ISSOCK(mode)) return UNIX_TYPE_SOCKET;
-#endif
-
- DEBUG(0,("unix_filetype: unknown filetype %u", (unsigned)mode));
- return UNIX_TYPE_UNKNOWN;
-}
-
-
/****************************************************************************
Change a unix mode to a dos mode.
****************************************************************************/
@@ -153,3 +101,37 @@ NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name)
return NT_STATUS_OK;
}
+
+
+/*
+ return a set of unix file permissions for a new file or directory
+*/
+mode_t pvfs_fileperms(struct pvfs_state *pvfs, uint32 attrib)
+{
+ mode_t mode = S_IRUSR | S_IRGRP | S_IROTH;
+
+ if (attrib & FILE_ATTRIBUTE_DIRECTORY) {
+ mode |= S_IXUSR | S_IXGRP | S_IXOTH;
+ }
+
+ if (!(attrib & FILE_ATTRIBUTE_READONLY)) {
+ mode |= S_IWUSR;
+ }
+
+ if ((attrib & FILE_ATTRIBUTE_ARCHIVE) &&
+ (pvfs->flags & PVFS_FLAG_MAP_ARCHIVE)) {
+ mode |= S_IXUSR;
+ }
+
+ if ((attrib & FILE_ATTRIBUTE_SYSTEM) &&
+ (pvfs->flags & PVFS_FLAG_MAP_SYSTEM)) {
+ mode |= S_IXGRP;
+ }
+
+ if ((attrib & FILE_ATTRIBUTE_HIDDEN) &&
+ (pvfs->flags & PVFS_FLAG_MAP_HIDDEN)) {
+ mode |= S_IXOTH;
+ }
+
+ return mode;
+}