2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1998
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "realcalls.h"
27 static struct smbw_file *smbw_files;
28 static struct smbw_server *smbw_srvs;
30 struct bitmap *smbw_file_bmap;
31 extern pstring global_myname;
32 extern int DEBUGLEVEL;
34 fstring smbw_prefix = SMBW_PREFIX;
38 /* needs to be here because of dumb include files on some systems */
39 int creat_bits = O_WRONLY|O_CREAT|O_TRUNC;
42 /*****************************************************
44 *******************************************************/
47 extern BOOL in_client;
48 static int initialised;
49 static pstring servicesf = CONFIGFILE;
55 if (initialised) return;
63 setup_logging("smbsh",True);
67 if ((p=smbw_getshared("LOGFILE"))) {
71 smbw_file_bmap = bitmap_allocate(SMBW_MAX_OPEN);
72 if (!smbw_file_bmap) {
82 lp_load(servicesf,True,False,False);
84 get_myname(global_myname,NULL);
86 if ((p=smbw_getshared("DEBUG"))) {
90 if ((p=smbw_getshared("RESOLVE_ORDER"))) {
91 lp_set_name_resolve_order(p);
94 if ((p=smbw_getshared("PREFIX"))) {
95 slprintf(smbw_prefix,sizeof(fstring)-1, "/%s/", p);
96 string_sub(smbw_prefix,"//", "/");
97 DEBUG(2,("SMBW_PREFIX is %s\n", smbw_prefix));
100 slprintf(line,sizeof(line)-1,"PWD_%d", getpid());
102 p = smbw_getshared(line);
106 pstrcpy(smbw_cwd, p);
107 DEBUG(4,("Initial cwd is %s\n", smbw_cwd));
111 set_maxfiles(SMBW_MAX_OPEN);
113 BlockSignals(True,SIGPIPE);
118 /*****************************************************
119 determine if a file descriptor is a smb one
120 *******************************************************/
123 if (smbw_busy) return 0;
124 return smbw_file_bmap && bitmap_query(smbw_file_bmap, fd);
127 /*****************************************************
128 determine if a file descriptor is an internal smbw fd
129 *******************************************************/
130 int smbw_local_fd(int fd)
132 struct smbw_server *srv;
136 if (smbw_busy) return 0;
137 if (smbw_shared_fd(fd)) return 1;
139 for (srv=smbw_srvs;srv;srv=srv->next) {
140 if (srv->cli.fd == fd) return 1;
146 /*****************************************************
147 a crude inode number generator
148 *******************************************************/
149 ino_t smbw_inode(const char *name)
151 if (!*name) return 2;
152 return (ino_t)str_checksum(name);
155 /*****************************************************
156 remove redundent stuff from a filename
157 *******************************************************/
158 void clean_fname(char *name)
169 DEBUG(5,("cleaning %s\n", name));
171 if ((p=strstr(name,"/./"))) {
179 if ((p=strstr(name,"//"))) {
187 if (strcmp(name,"/../")==0) {
192 if ((p=strstr(name,"/../"))) {
194 for (p2=(p>name?p-1:p);p2>name;p2--) {
195 if (p2[0] == '/') break;
203 if (strcmp(name,"/..")==0) {
209 p = l>=3?(name+l-3):name;
210 if (strcmp(p,"/..")==0) {
212 for (p2=p-1;p2>name;p2--) {
213 if (p2[0] == '/') break;
224 p = l>=2?(name+l-2):name;
225 if (strcmp(p,"/.")==0) {
233 if (strncmp(p=name,"./",2) == 0) {
241 if (l > 1 && p[l-1] == '/') {
249 /*****************************************************
250 parse a smb path into its components.
251 *******************************************************/
252 char *smbw_parse_path(const char *fname, char *server, char *share, char *path)
256 int len = strlen(smbw_prefix)-1;
258 *server = *share = *path = 0;
260 if (fname[0] == '/') {
263 slprintf(s,sizeof(s)-1, "%s/%s", smbw_cwd, fname);
267 DEBUG(5,("cleaned %s (fname=%s cwd=%s)\n",
268 s, fname, smbw_cwd));
270 if (strncmp(s,smbw_prefix,len) ||
271 (s[len] != '/' && s[len] != 0)) return s;
284 len = MIN(len,sizeof(fstring)-1);
286 strncpy(server, p, len);
292 char *workgroup = smbw_getshared("WORKGROUP");
293 if (!workgroup) workgroup = lp_workgroup();
294 slprintf(server,sizeof(fstring)-1, "%s#1D", workgroup);
296 fstrcpy(share,"IPC$");
310 len = MIN(len,sizeof(fstring)-1);
312 strncpy(share, p, len);
323 string_sub(path, "/", "\\");
326 DEBUG(4,("parsed path name=%s cwd=%s [%s] [%s] [%s]\n",
328 server, share, path));
333 /*****************************************************
334 determine if a path name (possibly relative) is in the
336 *******************************************************/
337 int smbw_path(const char *path)
339 fstring server, share;
344 /* this is needed to prevent recursion with the BSD malloc which
345 opens /etc/malloc.conf on the first call */
346 if (strncmp(path,"/etc/", 5) == 0) {
352 len = strlen(smbw_prefix)-1;
354 if (path[0] == '/' && strncmp(path,smbw_prefix,len)) {
358 if (smbw_busy) return 0;
360 DEBUG(3,("smbw_path(%s)\n", path));
362 cwd = smbw_parse_path(path, server, share, s);
364 if (strncmp(cwd,smbw_prefix,len) == 0 &&
365 (cwd[len] == '/' || cwd[len] == 0)) {
372 /*****************************************************
373 return a unix errno from a SMB error pair
374 *******************************************************/
375 int smbw_errno(struct cli_state *c)
381 ret = cli_error(c, &eclass, &ecode);
384 DEBUG(3,("smbw_error %d %d (0x%x) -> %d\n",
385 (int)eclass, (int)ecode, (int)ecode, ret));
390 /*****************************************************
391 return a connection to a server (existing or new)
392 *******************************************************/
393 struct smbw_server *smbw_server(char *server, char *share)
395 struct smbw_server *srv=NULL;
400 struct nmb_name called, calling;
401 char *p, *server_n = server;
405 extern struct in_addr ipzero;
410 username = smbw_getshared("USER");
411 if (!username) username = getenv("USER");
412 if (!username) username = "guest";
414 workgroup = smbw_getshared("WORKGROUP");
415 if (!workgroup) workgroup = lp_workgroup();
417 password = smbw_getshared("PASSWORD");
418 if (!password) password = "";
420 /* try to use an existing connection */
421 for (srv=smbw_srvs;srv;srv=srv->next) {
422 if (strcmp(server,srv->server_name)==0 &&
423 strcmp(share,srv->share_name)==0) return srv;
426 if (server[0] == 0) {
431 make_nmb_name(&calling, global_myname, 0x0, "");
432 make_nmb_name(&called , server, 0x20, "");
434 DEBUG(4,("server_n=[%s] server=[%s]\n", server_n, server));
436 if ((p=strchr(server_n,'#')) && strcmp(p+1,"1D")==0) {
440 fstrcpy(group, server_n);
441 p = strchr(group,'#');
444 /* cache the workgroup master lookup */
445 slprintf(s,sizeof(s)-1,"MASTER_%s", group);
446 if (!(server_n = smbw_getshared(s))) {
447 if (!find_master_ip(group, &sip)) {
451 fstrcpy(group, inet_ntoa(sip));
453 smbw_setshared(s,server_n);
457 DEBUG(4,(" -> server_n=[%s] server=[%s]\n", server_n, server));
460 slprintf(ipenv,sizeof(ipenv)-1,"HOST_%s", server_n);
463 if ((p=smbw_getshared(ipenv))) {
464 ip = *(interpret_addr2(p));
467 /* have to open a new connection */
468 if (!cli_initialise(&c) || !cli_connect(&c, server_n, &ip)) {
473 if (!cli_session_request(&c, &calling, &called)) {
475 if (strcmp(called.name, "*SMBSERVER")) {
476 make_nmb_name(&called , "*SMBSERVER", 0x20, "");
483 DEBUG(4,(" session request ok\n"));
485 if (!cli_negprot(&c)) {
491 if (!cli_session_setup(&c, username,
492 password, strlen(password),
493 password, strlen(password),
495 /* try an anonymous login if it failed */
496 !cli_session_setup(&c, "", "", 1,"", 0, workgroup)) {
502 DEBUG(4,(" session setup ok\n"));
504 if (!cli_send_tconX(&c, share, "?????",
505 password, strlen(password)+1)) {
506 errno = smbw_errno(&c);
511 smbw_setshared(ipenv,inet_ntoa(ip));
513 DEBUG(4,(" tconx ok\n"));
515 srv = (struct smbw_server *)malloc(sizeof(*srv));
525 srv->dev = (dev_t)(str_checksum(server) ^ str_checksum(share));
527 srv->server_name = strdup(server);
528 if (!srv->server_name) {
533 srv->share_name = strdup(share);
534 if (!srv->share_name) {
539 /* some programs play with file descriptors fairly intimately. We
540 try to get out of the way by duping to a high fd number */
541 if (fcntl(SMBW_CLI_FD + srv->cli.fd, F_GETFD) && errno == EBADF) {
542 if (dup2(srv->cli.fd,SMBW_CLI_FD+srv->cli.fd) ==
543 srv->cli.fd+SMBW_CLI_FD) {
545 srv->cli.fd += SMBW_CLI_FD;
549 DLIST_ADD(smbw_srvs, srv);
555 if (!srv) return NULL;
557 if (srv->server_name) free(srv->server_name);
558 if (srv->share_name) free(srv->share_name);
564 /*****************************************************
565 map a fd to a smbw_file structure
566 *******************************************************/
567 struct smbw_file *smbw_file(int fd)
569 struct smbw_file *file;
571 for (file=smbw_files;file;file=file->next) {
572 if (file->fd == fd) return file;
577 /*****************************************************
579 *******************************************************/
580 int smbw_open(const char *fname, int flags, mode_t mode)
582 fstring server, share;
584 struct smbw_server *srv=NULL;
586 struct smbw_file *file=NULL;
597 /* work out what server they are after */
598 smbw_parse_path(fname, server, share, path);
600 /* get a connection to the server */
601 srv = smbw_server(server, share);
603 /* smbw_server sets errno */
607 if (path[strlen(path)-1] == '\\') {
610 fd = cli_open(&srv->cli, path, flags, DENY_NONE);
613 /* it might be a directory. Maybe we should use chkpath? */
614 eno = smbw_errno(&srv->cli);
615 fd = smbw_dir_open(fname);
616 if (fd == -1) errno = eno;
621 file = (struct smbw_file *)malloc(sizeof(*file));
629 file->f = (struct smbw_filedes *)malloc(sizeof(*(file->f)));
635 ZERO_STRUCTP(file->f);
637 file->f->cli_fd = fd;
638 file->f->fname = strdup(path);
639 if (!file->f->fname) {
644 file->fd = open(SMBW_DUMMY, O_WRONLY);
645 if (file->fd == -1) {
650 if (bitmap_query(smbw_file_bmap, file->fd)) {
651 DEBUG(0,("ERROR: fd used in smbw_open\n"));
656 file->f->ref_count=1;
658 bitmap_set(smbw_file_bmap, file->fd);
660 DLIST_ADD(smbw_files, file);
662 DEBUG(4,("opened %s\n", fname));
669 cli_close(&srv->cli, fd);
673 if (file->f->fname) {
674 free(file->f->fname);
685 /*****************************************************
686 a wrapper for pread()
687 *******************************************************/
688 ssize_t smbw_pread(int fd, void *buf, size_t count, off_t ofs)
690 struct smbw_file *file;
695 file = smbw_file(fd);
702 ret = cli_read(&file->srv->cli, file->f->cli_fd, buf, ofs, count);
705 errno = smbw_errno(&file->srv->cli);
714 /*****************************************************
716 *******************************************************/
717 ssize_t smbw_read(int fd, void *buf, size_t count)
719 struct smbw_file *file;
722 DEBUG(4,("smbw_read(%d, %d)\n", fd, (int)count));
726 file = smbw_file(fd);
733 ret = cli_read(&file->srv->cli, file->f->cli_fd, buf,
734 file->f->offset, count);
737 errno = smbw_errno(&file->srv->cli);
742 file->f->offset += ret;
744 DEBUG(4,(" -> %d\n", ret));
752 /*****************************************************
753 a wrapper for write()
754 *******************************************************/
755 ssize_t smbw_write(int fd, void *buf, size_t count)
757 struct smbw_file *file;
762 file = smbw_file(fd);
769 ret = cli_write(&file->srv->cli, file->f->cli_fd, 0, buf, file->f->offset, count);
772 errno = smbw_errno(&file->srv->cli);
777 file->f->offset += ret;
783 /*****************************************************
784 a wrapper for pwrite()
785 *******************************************************/
786 ssize_t smbw_pwrite(int fd, void *buf, size_t count, off_t ofs)
788 struct smbw_file *file;
793 file = smbw_file(fd);
800 ret = cli_write(&file->srv->cli, file->f->cli_fd, 0, buf, ofs, count);
803 errno = smbw_errno(&file->srv->cli);
812 /*****************************************************
813 a wrapper for close()
814 *******************************************************/
815 int smbw_close(int fd)
817 struct smbw_file *file;
821 file = smbw_file(fd);
823 int ret = smbw_dir_close(fd);
828 if (file->f->ref_count == 1 &&
829 !cli_close(&file->srv->cli, file->f->cli_fd)) {
830 errno = smbw_errno(&file->srv->cli);
836 bitmap_clear(smbw_file_bmap, file->fd);
839 DLIST_REMOVE(smbw_files, file);
841 file->f->ref_count--;
842 if (file->f->ref_count == 0) {
843 free(file->f->fname);
855 /*****************************************************
856 a wrapper for fcntl()
857 *******************************************************/
858 int smbw_fcntl(int fd, int cmd, long arg)
864 /*****************************************************
865 a wrapper for access()
866 *******************************************************/
867 int smbw_access(const char *name, int mode)
871 DEBUG(4,("smbw_access(%s, 0x%x)\n", name, mode));
873 if (smbw_stat(name, &st)) return -1;
875 if (((mode & R_OK) && !(st.st_mode & S_IRUSR)) ||
876 ((mode & W_OK) && !(st.st_mode & S_IWUSR)) ||
877 ((mode & X_OK) && !(st.st_mode & S_IXUSR))) {
885 /*****************************************************
886 a wrapper for realink() - needed for correct errno setting
887 *******************************************************/
888 int smbw_readlink(const char *path, char *buf, size_t bufsize)
893 ret = smbw_stat(path, &st);
895 DEBUG(4,("readlink(%s) failed\n", path));
899 /* it exists - say it isn't a link */
900 DEBUG(4,("readlink(%s) not a link\n", path));
907 /*****************************************************
908 a wrapper for unlink()
909 *******************************************************/
910 int smbw_unlink(const char *fname)
912 struct smbw_server *srv;
913 fstring server, share;
925 /* work out what server they are after */
926 smbw_parse_path(fname, server, share, path);
928 /* get a connection to the server */
929 srv = smbw_server(server, share);
931 /* smbw_server sets errno */
935 if (strncmp(srv->cli.dev, "LPT", 3) == 0) {
936 int job = smbw_stat_printjob(srv, path, NULL, NULL);
940 if (cli_printjob_del(&srv->cli, job) != 0) {
943 } else if (!cli_unlink(&srv->cli, path)) {
944 errno = smbw_errno(&srv->cli);
957 /*****************************************************
958 a wrapper for rename()
959 *******************************************************/
960 int smbw_rename(const char *oldname, const char *newname)
962 struct smbw_server *srv;
963 fstring server1, share1;
965 fstring server2, share2;
968 if (!oldname || !newname) {
975 DEBUG(4,("smbw_rename(%s,%s)\n", oldname, newname));
979 /* work out what server they are after */
980 smbw_parse_path(oldname, server1, share1, path1);
981 smbw_parse_path(newname, server2, share2, path2);
983 if (strcmp(server1, server2) || strcmp(share1, share2)) {
984 /* can't cross filesystems */
989 /* get a connection to the server */
990 srv = smbw_server(server1, share1);
992 /* smbw_server sets errno */
996 if (!cli_rename(&srv->cli, path1, path2)) {
997 int eno = smbw_errno(&srv->cli);
999 !cli_unlink(&srv->cli, path2) ||
1000 !cli_rename(&srv->cli, path1, path2)) {
1015 /*****************************************************
1016 a wrapper for utime and utimes
1017 *******************************************************/
1018 static int smbw_settime(const char *fname, time_t t)
1020 struct smbw_server *srv;
1021 fstring server, share;
1034 /* work out what server they are after */
1035 smbw_parse_path(fname, server, share, path);
1037 /* get a connection to the server */
1038 srv = smbw_server(server, share);
1040 /* smbw_server sets errno */
1044 if (!cli_getatr(&srv->cli, path, &mode, NULL, NULL)) {
1045 errno = smbw_errno(&srv->cli);
1049 if (!cli_setatr(&srv->cli, path, mode, t)) {
1050 /* some servers always refuse directory changes */
1051 if (!(mode & aDIR)) {
1052 errno = smbw_errno(&srv->cli);
1065 /*****************************************************
1067 *******************************************************/
1068 int smbw_utime(const char *fname, void *buf)
1070 struct utimbuf *tbuf = (struct utimbuf *)buf;
1071 return smbw_settime(fname, tbuf?tbuf->modtime:time(NULL));
1074 /*****************************************************
1076 *******************************************************/
1077 int smbw_utimes(const char *fname, void *buf)
1079 struct timeval *tbuf = (struct timeval *)buf;
1080 return smbw_settime(fname, tbuf?tbuf->tv_sec:time(NULL));
1084 /*****************************************************
1085 a wrapper for chown()
1086 *******************************************************/
1087 int smbw_chown(const char *fname, uid_t owner, gid_t group)
1089 struct smbw_server *srv;
1090 fstring server, share;
1103 /* work out what server they are after */
1104 smbw_parse_path(fname, server, share, path);
1106 /* get a connection to the server */
1107 srv = smbw_server(server, share);
1109 /* smbw_server sets errno */
1113 if (!cli_getatr(&srv->cli, path, &mode, NULL, NULL)) {
1114 errno = smbw_errno(&srv->cli);
1118 /* assume success */
1128 /*****************************************************
1129 a wrapper for chmod()
1130 *******************************************************/
1131 int smbw_chmod(const char *fname, mode_t newmode)
1133 struct smbw_server *srv;
1134 fstring server, share;
1147 /* work out what server they are after */
1148 smbw_parse_path(fname, server, share, path);
1150 /* get a connection to the server */
1151 srv = smbw_server(server, share);
1153 /* smbw_server sets errno */
1159 if (!(newmode & (S_IWUSR | S_IWGRP | S_IWOTH))) mode |= aRONLY;
1160 if ((newmode & S_IXUSR) && lp_map_archive(-1)) mode |= aARCH;
1161 if ((newmode & S_IXGRP) && lp_map_system(-1)) mode |= aSYSTEM;
1162 if ((newmode & S_IXOTH) && lp_map_hidden(-1)) mode |= aHIDDEN;
1164 if (!cli_setatr(&srv->cli, path, mode, 0)) {
1165 errno = smbw_errno(&srv->cli);
1177 /*****************************************************
1178 a wrapper for lseek()
1179 *******************************************************/
1180 off_t smbw_lseek(int fd, off_t offset, int whence)
1182 struct smbw_file *file;
1187 file = smbw_file(fd);
1189 off_t ret = smbw_dir_lseek(fd, offset, whence);
1196 file->f->offset = offset;
1199 file->f->offset += offset;
1202 if (!cli_qfileinfo(&file->srv->cli, file->f->cli_fd,
1203 NULL, &size, NULL, NULL, NULL,
1205 !cli_getattrE(&file->srv->cli, file->f->cli_fd,
1206 NULL, &size, NULL, NULL, NULL)) {
1211 file->f->offset = size + offset;
1216 return file->f->offset;
1220 /*****************************************************
1222 *******************************************************/
1223 int smbw_dup(int fd)
1226 struct smbw_file *file, *file2;
1230 file = smbw_file(fd);
1236 fd2 = dup(file->fd);
1241 if (bitmap_query(smbw_file_bmap, fd2)) {
1242 DEBUG(0,("ERROR: fd already open in dup!\n"));
1247 file2 = (struct smbw_file *)malloc(sizeof(*file2));
1254 ZERO_STRUCTP(file2);
1259 file->f->ref_count++;
1261 bitmap_set(smbw_file_bmap, fd2);
1263 DLIST_ADD(smbw_files, file2);
1274 /*****************************************************
1275 a wrapper for dup2()
1276 *******************************************************/
1277 int smbw_dup2(int fd, int fd2)
1279 struct smbw_file *file, *file2;
1283 file = smbw_file(fd);
1289 if (bitmap_query(smbw_file_bmap, fd2)) {
1290 DEBUG(0,("ERROR: fd already open in dup2!\n"));
1295 if (dup2(file->fd, fd2) != fd2) {
1299 file2 = (struct smbw_file *)malloc(sizeof(*file2));
1306 ZERO_STRUCTP(file2);
1311 file->f->ref_count++;
1313 bitmap_set(smbw_file_bmap, fd2);
1315 DLIST_ADD(smbw_files, file2);
1326 /*****************************************************
1327 close a connection to a server
1328 *******************************************************/
1329 static void smbw_srv_close(struct smbw_server *srv)
1333 cli_shutdown(&srv->cli);
1335 free(srv->server_name);
1336 free(srv->share_name);
1338 DLIST_REMOVE(smbw_srvs, srv);
1347 /*****************************************************
1348 when we fork we have to close all connections and files
1350 *******************************************************/
1358 struct smbw_file *file, *next_file;
1359 struct smbw_server *srv, *next_srv;
1361 if (pipe(p)) return real_fork();
1363 child = real_fork();
1366 /* block the parent for a moment until the sockets are
1376 /* close all files */
1377 for (file=smbw_files;file;file=next_file) {
1378 next_file = file->next;
1382 /* close all server connections */
1383 for (srv=smbw_srvs;srv;srv=next_srv) {
1384 next_srv = srv->next;
1385 smbw_srv_close(srv);
1388 slprintf(line,sizeof(line)-1,"PWD_%d", getpid());
1389 smbw_setshared(line,smbw_cwd);
1391 /* unblock the parent */
1395 /* and continue in the child */
1399 #ifndef NO_ACL_WRAPPER
1400 /*****************************************************
1402 *******************************************************/
1403 int smbw_acl(const char *pathp, int cmd, int nentries, aclent_t *aclbufp)
1405 if (cmd == GETACL || cmd == GETACLCNT) return 0;
1411 #ifndef NO_FACL_WRAPPER
1412 /*****************************************************
1414 *******************************************************/
1415 int smbw_facl(int fd, int cmd, int nentries, aclent_t *aclbufp)
1417 if (cmd == GETACL || cmd == GETACLCNT) return 0;
1425 /* this can't be in wrapped.c because of include conflicts */
1426 void stat64_convert(struct stat *st, struct stat64 *st64)
1428 st64->st_size = st->st_size;
1429 st64->st_mode = st->st_mode;
1430 st64->st_ino = st->st_ino;
1431 st64->st_dev = st->st_dev;
1432 st64->st_rdev = st->st_rdev;
1433 st64->st_nlink = st->st_nlink;
1434 st64->st_uid = st->st_uid;
1435 st64->st_gid = st->st_gid;
1436 st64->st_atime = st->st_atime;
1437 st64->st_mtime = st->st_mtime;
1438 st64->st_ctime = st->st_ctime;
1439 st64->st_blksize = st->st_blksize;
1440 st64->st_blocks = st->st_blocks;
1444 #ifdef HAVE_READDIR64
1445 void dirent64_convert(struct dirent *d, struct dirent64 *d64)
1447 d64->d_ino = d->d_ino;
1448 d64->d_off = d->d_off;
1449 d64->d_reclen = d->d_reclen;
1450 pstrcpy(d64->d_name, d->d_name);
1456 /* Definition of `struct stat' used in the linux kernel.. */
1457 struct kernel_stat {
1458 unsigned short int st_dev;
1459 unsigned short int __pad1;
1460 unsigned long int st_ino;
1461 unsigned short int st_mode;
1462 unsigned short int st_nlink;
1463 unsigned short int st_uid;
1464 unsigned short int st_gid;
1465 unsigned short int st_rdev;
1466 unsigned short int __pad2;
1467 unsigned long int st_size;
1468 unsigned long int st_blksize;
1469 unsigned long int st_blocks;
1470 unsigned long int st_atime;
1471 unsigned long int __unused1;
1472 unsigned long int st_mtime;
1473 unsigned long int __unused2;
1474 unsigned long int st_ctime;
1475 unsigned long int __unused3;
1476 unsigned long int __unused4;
1477 unsigned long int __unused5;
1481 * Prototype for gcc in 'fussy' mode.
1483 void xstat_convert(int vers, struct stat *st, struct kernel_stat *kbuf);
1484 void xstat_convert(int vers, struct stat *st, struct kernel_stat *kbuf)
1486 #ifdef _STAT_VER_LINUX_OLD
1487 if (vers == _STAT_VER_LINUX_OLD) {
1488 memcpy(st, kbuf, sizeof(*st));
1495 st->st_dev = kbuf->st_dev;
1496 st->st_ino = kbuf->st_ino;
1497 st->st_mode = kbuf->st_mode;
1498 st->st_nlink = kbuf->st_nlink;
1499 st->st_uid = kbuf->st_uid;
1500 st->st_gid = kbuf->st_gid;
1501 st->st_rdev = kbuf->st_rdev;
1502 st->st_size = kbuf->st_size;
1503 st->st_blksize = kbuf->st_blksize;
1504 st->st_blocks = kbuf->st_blocks;
1505 st->st_atime = kbuf->st_atime;
1506 st->st_mtime = kbuf->st_mtime;
1507 st->st_ctime = kbuf->st_ctime;