Hi Pete, Sam,
I have committed a patch that looks like the attached.
It seems to build fine..
Objections?
thanks,
Murali
On Wed, 13 Sep 2006, Pete Wyckoff wrote:
> [EMAIL PROTECTED] wrote on Wed, 13 Sep 2006 11:29 -0500:
> > It needs the PVFS2_translate_mode function at least (kernel/linux-2.6/
> > pvfs2-util.c calls it). Even though we don't have any shared source
> > files right now, I don't see any reason why we couldn't. Could the
> > makefile just list a relative path to a pvfs2-shared.c source file
> > in ../../common/misc?
>
> But I expect both kernel and client build want to create a .o file
> for that single source file. You'd have to add some special rule
> to make sure those don't collide, or do symlink magic, both of which
> are icky. It's not so huge that having two copies is a big deal.
> And not like we'll add any more perm bits in the near future.
>
> You could always do the super icky #include <somefile.c> to pull it
> into two otherwise empty compilation units, if this duplication
> really bothers you.
>
> Or you can do like the endecode stuff. In the C files that need it,
> define __NEED_PVFS_TRANSLATE_MODE. Then in the header file, leave
> the function as is (minus the inline) and wrap it with an #ifdef so
> that only the two compilation units (some kernel C file and some
> user C file) that need the definition, get it. All others just get
> a declaration.
>
> -- Pete
> _______________________________________________
> Pvfs2-developers mailing list
> Pvfs2-developers@beowulf-underground.org
> http://www.beowulf-underground.org/mailman/listinfo/pvfs2-developers
>
>
Index: include/pvfs2-util.h
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/include/pvfs2-util.h,v
retrieving revision 1.45
diff -u -r1.45 pvfs2-util.h
--- include/pvfs2-util.h 11 Sep 2006 20:22:00 -0000 1.45
+++ include/pvfs2-util.h 13 Sep 2006 18:25:34 -0000
@@ -95,101 +95,22 @@
uint32_t PVFS_util_object_to_sys_attr_mask(
uint32_t obj_mask);
-static inline int PVFS2_translate_mode(int mode, int suid)
-{
- int ret = 0, i = 0;
-#define NUM_MODES 11
- static int modes[NUM_MODES] =
- {
- S_IXOTH, S_IWOTH, S_IROTH,
- S_IXGRP, S_IWGRP, S_IRGRP,
- S_IXUSR, S_IWUSR, S_IRUSR,
- S_ISGID, S_ISUID
- };
- static int pvfs2_modes[NUM_MODES] =
- {
- PVFS_O_EXECUTE, PVFS_O_WRITE, PVFS_O_READ,
- PVFS_G_EXECUTE, PVFS_G_WRITE, PVFS_G_READ,
- PVFS_U_EXECUTE, PVFS_U_WRITE, PVFS_U_READ,
- PVFS_G_SGID, PVFS_U_SUID
- };
-
- for(i = 0; i < NUM_MODES; i++)
- {
- if (mode & modes[i])
- {
- ret |= pvfs2_modes[i];
- }
- }
- if (suid == 0 && (ret & PVFS_U_SUID))
- {
- ret &= ~PVFS_U_SUID;
- }
- return ret;
-#undef NUM_MODES
-}
+int32_t PVFS_translate_mode(int mode, int suid);
#ifndef __KERNEL__
-inline static PVFS_time PVFS_util_get_current_time(void)
-{
- struct timeval t = {0,0};
- PVFS_time current_time = 0;
-
- gettimeofday(&t, NULL);
- current_time = (PVFS_time)t.tv_sec;
- return current_time;
-}
-
-inline static PVFS_time PVFS_util_mktime_version(PVFS_time time)
-{
- struct timeval t = {0,0};
- PVFS_time version = (time << 32);
-
- gettimeofday(&t, NULL);
- version |= (PVFS_time)t.tv_usec;
- return version;
-}
-
-inline static PVFS_time PVFS_util_mkversion_time(PVFS_time version)
-{
- return (PVFS_time)(version >> 32);
-}
+PVFS_time PVFS_util_get_current_time(void);
+PVFS_time PVFS_util_mktime_version(PVFS_time time);
+PVFS_time PVFS_util_mkversion_time(PVFS_time version);
void PINT_util_digest_init(void);
void PINT_util_digest_finalize(void);
-
int PINT_util_digest_sha1(const void *input_message, size_t input_length,
char **output, size_t *output_length);
-
int PINT_util_digest_md5(const void *input_message, size_t input_length,
char **output, size_t *output_length);
-
#endif /* __KERNEL__ */
-static inline char *get_object_type(int objtype)
-{
- static char *obj_types[] =
- {
- "NONE", "METAFILE", "DATAFILE",
- "DIRECTORY", "SYMLINK", "DIRDATA", "UNKNOWN"
- };
- switch(objtype)
- {
- case PVFS_TYPE_NONE:
- return obj_types[0];
- case PVFS_TYPE_METAFILE:
- return obj_types[1];
- case PVFS_TYPE_DATAFILE:
- return obj_types[2];
- case PVFS_TYPE_DIRECTORY:
- return obj_types[3];
- case PVFS_TYPE_SYMLINK:
- return obj_types[4];
- case PVFS_TYPE_DIRDATA:
- return obj_types[5];
- }
- return obj_types[6];
-}
+char *get_object_type(int objtype);
#endif /* __PVFS2_UTIL_H */
Index: src/apps/admin/pvfs2-cp.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-cp.c,v
retrieving revision 1.21
diff -u -r1.21 pvfs2-cp.c
--- src/apps/admin/pvfs2-cp.c 11 Sep 2006 20:22:01 -0000 1.21
+++ src/apps/admin/pvfs2-cp.c 13 Sep 2006 18:25:34 -0000
@@ -682,7 +682,7 @@
{
attr->owner = credentials->uid;
attr->group = credentials->gid;
- attr->perms = PVFS2_translate_mode(mode, 0);
+ attr->perms = PVFS_translate_mode(mode, 0);
attr->mask = (PVFS_ATTR_SYS_ALL_SETABLE);
attr->dfile_count = nr_datafiles;
Index: src/apps/admin/pvfs2-fsck.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-fsck.c,v
retrieving revision 1.18
diff -u -r1.18 pvfs2-fsck.c
--- src/apps/admin/pvfs2-fsck.c 11 Sep 2006 20:22:01 -0000 1.18
+++ src/apps/admin/pvfs2-fsck.c 13 Sep 2006 18:25:34 -0000
@@ -1034,7 +1034,7 @@
attr.owner = creds->uid;
attr.owner = creds->uid;
attr.group = creds->gid;
- attr.perms = PVFS2_translate_mode(0755, 0);
+ attr.perms = PVFS_translate_mode(0755, 0);
attr.mask = PVFS_ATTR_SYS_ALL_SETABLE;
ret = PVFS_sys_lookup(cur_fs,
Index: src/apps/admin/pvfs2-mkdir.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-mkdir.c,v
retrieving revision 1.10
diff -u -r1.10 pvfs2-mkdir.c
--- src/apps/admin/pvfs2-mkdir.c 11 Sep 2006 20:22:01 -0000 1.10
+++ src/apps/admin/pvfs2-mkdir.c 13 Sep 2006 18:25:34 -0000
@@ -456,7 +456,7 @@
if(!mode_requested)
{
mode_t mode = S_IRWXO | S_IRWXG | S_IRWXU; /* 0777 */
- opts->mode = PVFS2_translate_mode(mode & ~PVFS_util_get_umask(), 0);
+ opts->mode = PVFS_translate_mode(mode & ~PVFS_util_get_umask(), 0);
}
/* Allocate memory to hold the filenames */
Index: src/common/misc/module.mk.in
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/common/misc/module.mk.in,v
retrieving revision 1.27
diff -u -r1.27 module.mk.in
--- src/common/misc/module.mk.in 11 Sep 2006 00:38:45 -0000 1.27
+++ src/common/misc/module.mk.in 13 Sep 2006 18:25:34 -0000
@@ -3,6 +3,7 @@
$(DIR)/server-config-mgr.c \
$(DIR)/str-utils.c \
$(DIR)/digest.c \
+ $(DIR)/pvfs2-shared.c \
$(DIR)/xattr-utils.c \
$(DIR)/mmap-ra-cache.c \
$(DIR)/extent-utils.c \
@@ -21,6 +22,7 @@
$(DIR)/str-utils.c \
$(DIR)/extent-utils.c \
$(DIR)/errno-mapping.c \
+ $(DIR)/pvfs2-shared.c \
$(DIR)/mkspace.c \
$(DIR)/pvfs2-debug.c \
$(DIR)/pint-perf-counter.c \
Index: src/kernel/linux-2.6/Makefile.in
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/Makefile.in,v
retrieving revision 1.22
diff -u -r1.22 Makefile.in
--- src/kernel/linux-2.6/Makefile.in 10 Aug 2006 19:02:24 -0000 1.22
+++ src/kernel/linux-2.6/Makefile.in 13 Sep 2006 18:25:34 -0000
@@ -49,6 +49,7 @@
xattr-trusted.c \
xattr-default.c \
waitqueue.c \
+ ../../common/misc/pvfs2-shared.c \
pvfs2-proc.c
hsrc = \
pvfs2-kernel.h \
@@ -71,6 +72,8 @@
-I$(absolute_src_dir)/include \
-I$(absolute_src_dir)/src/io/dev \
-I$(absolute_src_dir)/src/io/bmi \
+ -I$(absolute_src_dir)/src/kernel/linux-2.6 \
+ -I$(absolute_src_dir)/src/kernel/linux-2.4 \
-I$(absolute_src_dir)/src/common/quickhash \
-I$(absolute_src_dir)/src/common/gossip \
-I$(absolute_src_dir)/src/common/misc
Index: src/kernel/linux-2.6/pvfs2-kernel.h
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/pvfs2-kernel.h,v
retrieving revision 1.127
diff -u -r1.127 pvfs2-kernel.h
--- src/kernel/linux-2.6/pvfs2-kernel.h 11 Sep 2006 20:22:05 -0000 1.127
+++ src/kernel/linux-2.6/pvfs2-kernel.h 13 Sep 2006 18:25:35 -0000
@@ -933,7 +933,7 @@
sys_attr.owner = current->fsuid; \
sys_attr.group = current->fsgid; \
sys_attr.size = 0; \
- sys_attr.perms = PVFS2_translate_mode(mode,0); \
+ sys_attr.perms = PVFS_translate_mode(mode,0); \
sys_attr.objtype = type; \
sys_attr.mask = PVFS_ATTR_SYS_ALL_SETABLE; \
} while(0)
@@ -957,7 +957,7 @@
sys_attr.owner = current->fsuid; \
sys_attr.group = current->fsgid; \
sys_attr.size = 0; \
- sys_attr.perms = PVFS2_translate_mode(mode,0); \
+ sys_attr.perms = PVFS_translate_mode(mode,0); \
sys_attr.objtype = type; \
sys_attr.mask = PVFS_ATTR_SYS_ALL_SETABLE; \
} while(0)
Index: src/kernel/linux-2.6/pvfs2-utils.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/pvfs2-utils.c,v
retrieving revision 1.135
diff -u -r1.135 pvfs2-utils.c
--- src/kernel/linux-2.6/pvfs2-utils.c 11 Sep 2006 20:22:05 -0000 1.135
+++ src/kernel/linux-2.6/pvfs2-utils.c 13 Sep 2006 18:25:36 -0000
@@ -300,7 +300,7 @@
PVFS_sys_attr *attrs,
int suid)
{
- attrs->perms = PVFS2_translate_mode(mode, suid);
+ attrs->perms = PVFS_translate_mode(mode, suid);
attrs->mask |= PVFS_ATTR_SYS_PERM;
gossip_debug(GOSSIP_UTILS_DEBUG, "mode is %d | translated perms is %d\n",
mode,
_______________________________________________
Pvfs2-developers mailing list
Pvfs2-developers@beowulf-underground.org
http://www.beowulf-underground.org/mailman/listinfo/pvfs2-developers