mars_nwe-0.98.pl08

This commit is contained in:
Mario Fetka 2011-11-13 00:38:58 +01:00
parent 309ae4659e
commit 519bf6bfcd
21 changed files with 1323 additions and 949 deletions

View File

@ -99,40 +99,40 @@ static int new_dir_handle(ino_t inode, NW_PATH *nwpath)
DIR_HANDLE *dh = NULL;
time_t akttime = time(NULL);
time_t last_time = akttime;
int thandle = 0;
int thandle = 1;
int nhandle = 0;
for (rethandle=0; rethandle < anz_dirhandles; rethandle++){
dh=&(dir_handles[rethandle]);
if (!dh->inode) {
if (!nhandle) nhandle = rethandle+1;
if (!nhandle)
nhandle = rethandle+1;
} else if (dh->inode == inode && dh->volume == nwpath->volume){
/* Dieser hat Vorrang */
if (dh->f) closedir(dh->f);
dh->f = NULL;
dh->timestamp = akttime;
nhandle = rethandle+1;
nhandle = rethandle+1;
break;
} else if (dh->timestamp < last_time){
thandle = rethandle+1;
last_time = dh->timestamp;
}
}
if (!nhandle){
if (anz_dirhandles < MAX_DIRHANDLES) {
if (anz_dirhandles < MAX_DIRHANDLES) {
dh=&(dir_handles[anz_dirhandles]);
dh->f=NULL;
rethandle = ++anz_dirhandles;
} else {
dh=&(dir_handles[thandle-1]);
if (dh->f) closedir(dh->f);
dh->f = NULL;
rethandle = thandle;
}
} else rethandle=nhandle;
} else
rethandle=nhandle;
/* init dir_handle */
dh=&(dir_handles[rethandle-1]);
strcpy(dh->unixname, build_unix_name(nwpath, 0));
dh->kpath = dh->unixname + strlen(dh->unixname);
if (dh->f)
closedir(dh->f);
if ((dh->f = opendir(dh->unixname)) != (DIR*) NULL){
dh->volume = nwpath->volume;
dh->vol_options = nw_volumes[dh->volume].options;
@ -145,10 +145,10 @@ static int new_dir_handle(ino_t inode, NW_PATH *nwpath)
dh->f = NULL;
}
} else {
dh->f = (DIR*)NULL;
dh->inode = 0;
dh->unixname[0] = '\0';
dh->vol_options = 0;
dh->kpath = (char*)NULL;
dh->kpath = dh->unixname;
rethandle = /* -0x9c */ -0xff;
}
return(rethandle);

View File

@ -8,7 +8,8 @@
*/
/* NWCONN */
#define D_FH_OPEN 1 /* file open/close */
#define D_FH_OPEN 1 /* file open/close */
#define D_FH_LOCK 2 /* file lock/unlock */
#endif

View File

@ -1,6 +1,6 @@
Sorry, this is in German only.
User important notes are in the NEWS file.
Aenderungen in mars_nwe bis zum : 15-Dec-96
Aenderungen in mars_nwe bis zum : 17-Jan-97
--------------------------------
Erste 'oeffentliche' Version
^^^^^^^^^^ VERSION 0.94 ^^^^^^^^
@ -266,4 +266,11 @@ Erste 'oeffentliche' Version
Es konnten nicht alle freigegebenen Filehandles wiederverwendet
werden. -> "No more free file handles"
<----- ^^^^^^^^^^ pl7 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Section 6: version-"spoofing" auf default '1' (3.11) gesetzt.
- Fehler in connect.c, new_dir_handle() beseitigt.
Hinweis von: Dmitry <mamatkazin@ivc.spb.ru>
- QUOTA support von Matt Paley eingebaut.
- Print Queue Command Parameter erweitert um '!'
fuer banner_user_name, banner_file_name
<----- ^^^^^^^^^^ pl8 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -31,6 +31,9 @@ James B. MacLean <macleajb@ednet.ns.ca>
Louis Zammit Mangion <lzamm@phys.um.edu.mt>
testings+bugfixes
Matt Paley <mtpa@mail.nerc-bas.ac.uk>
adding QUOTA support, login time restrictions
Jiri A. Randus <Jiri.Randus@vslib.cz>
testing bindery code

View File

@ -1,9 +1,8 @@
last updated: 05-Dec-96
last updated: 16-Jan-97
Q: I don't exaclty understand the meaning of some ponits in nw.ini:
12,13
What will happen if I will not put PASSWORD here? Will it take it from
/etc/passwd? I want it to be so.
A: This passwords will be stored (crypted) into bindery to can handle
the crypted login call from a standarrd Novell client.
@ -41,6 +40,16 @@ Q: I have arcnet cards and I dont find the frame-typ TRXNET.
A: The correct frame typ is handled by the arcnet driver.
You should use the 'dummy frametyp' 802.3.
Q: The CONFIG_IPX_INTERN kernel option is *not* set but
when I start 'nwserv' as root it sais:
!! NWSERV 0:PANIC !!
NWSERV 0:!! configuration error !!:
mars_nwe don't run with kernel 'full internal net'.
Change kernel option CONFIG_IPX_INTERN=NO (nobody needs it)
or use 'ipxd' and change mars_nwe INTERNAL_RIP_SAP=0.
A: Sorry but mars_nwe can recognize this setting only at compile time,
so you must compile mars_nwe again with actual kernel CONFIG_IPX_INTERN=NO
settings.

View File

@ -1,5 +1,16 @@
# in this files are some notes for user of mars_nwe.
------09-Nov-96--- 0.98.pl7 ----------
------29-Jan-97--- 0.98.pl8 ----------
- Section 6: version-"spoofing" now set to '1' (3.11) default.
- New switch in config.h: QUOTA_SUPPORT
- quota support added by Matt Paley
Before the netware quotas will work the linux quota system must be
started up, this is done by:
Ensuring that the current kernel supports quotas.
Adding usrquota to the option field in the appropriate /etc/fstab entry
Running 'quotacheck -a'
Running 'quotaon -a' (must be repeated after a reboot)
- login time restrictions added by Matt Paley
------05-Jan-97--- 0.98.pl7 ----------
- section 8: new flag 0x4 added. (see examples/nw.ini).
------09-Nov-96--- 0.98.pl5 ----------
- now Novell Client32 should works.

View File

@ -1,7 +1,7 @@
Begin3
Title: mars_nwe
Version: 0.98.pl7
Entered-date: 09-Jan-97
Version: 0.98.pl8
Entered-date: 01-Feb-97
Description: Full netware-emulator (src), beta.
Supports file-services, bindery-services,
printing-services, routing-services.
@ -9,7 +9,7 @@ Keywords: novell, netware, server, ipx, ncp, tli
Author: mstover@stover.f.eunet.de (Martin Stover)
Maintained-by: mstover@stover.f.eunet.de (Martin Stover)
Primary-site: ftp.gwdg.de:/pub/linux/misc/ncpfs
200kB mars_nwe-0.98.pl7.tgz
200kB mars_nwe-0.98.pl8.tgz
Alternate-site: sunsite.unc.edu:/pub/Linux/system/Filesystems/ncpfs
Platforms: Linux (1.2.xx, 1.3.xx, 2.xx), UnixWare (2.xx)
Copying-policy: GNU

View File

@ -1,4 +1,4 @@
/* config.h: 04-Nov-96 */
/* config.h: 29-Jan-97 */
/* some of this config is needed by make, others by cc */
#define DO_DEBUG 1 /* compile in debug code */
@ -75,4 +75,5 @@
#define MAX_RIP_ENTRIES 50 /* max. rip responses */
/* -------------------- */
#define SHADOW_PWD 0 /* change to '1' for shadow passwds */
#define QUOTA_SUPPORT 0 /* change to '1' for quota support */

View File

@ -2,7 +2,7 @@
# This is the configuration-file for "mars_nwe", a free netware-emulator
# for Linux.
#
# last changed: 20-Nov-96
# last changed: 29-Jan-97
# This file specifies which Linux-resources (printers, users, directories)
# should be accessible to the DOS-clients via "mars_nwe". Furthermore
@ -252,24 +252,22 @@
# Some clients work better if the server tells that it is a 3.11 Server,
# although many calls (namespace services) of a real 3.11 Server are
# missing yet.
# To test the namespace calls, this entry must be set to > 0 and `config.h'
# must be altered before compiling "mars_nwe".
#
# -------------------------------------------------------------------------
# Syntax:
# 6 SERVER_VERSION
#
# SERVER_VERSION: the version-number reported to DOS-clients
# 0 Version 2.15 (default)
# 1 Version 3.11 (will be default soon)
# 0 Version 2.15 (was default till version 0.98.pl7)
# 1 Version 3.11 (is default now)
# 2 Version 3.12 (burst mode is not implemented yet)
#
# If you want to use longfilenamesupport and/or namespace routines
# you should set this section to '1'.
# And you should read doc/FAQS.
# -------------------------------------------------------------------------
#
6 0
6 1
# =========================================================================
@ -323,6 +321,8 @@
# normally the rename file call returns an error if this
# routine is used for renaming directories.
#
# 0x8 ignore station/time restrictions for supervisor.
#
# other flags may follow.
# value will be interpreted as hex value.
@ -528,6 +528,10 @@
# (_not_ the spooling-directories of the Linux-lpd)
# PRINT_COMMAND: command used for serving the print-jobs under Linux
# (see "man lpr" and "man magicfilter" for details)
# if the '!' is last parameter of command then
# the queue-packet fields 'banner_user_name'
# and 'banner_file_name' will be added to the
# command as last parameters.
#
# Examples:
# 21 LASER SYS:/PRINT/L lpr -Plaser
@ -603,7 +607,7 @@
# Section 402: station connect restrictions
#
# for special handling of the 'creat connection' call.
# for special handling of the 'creat connection' (attach) call.
402 0 # 0 = ignore entry 400, create connection always enabled.
# 1 = 400 are excludes, create connection normally enabled.
# 2 = 400 are includes, create connection normally disabled.

View File

@ -1,5 +1,5 @@
#if 0
#makefile.unx 14-Nov-96
#makefile.unx 09-Jan-97
#endif
VPATH=$(V_VPATH)
@ -9,7 +9,7 @@ C=.c
V_H=0
V_L=98
P_L=7
P_L=8
#define D_P_L 1
DISTRIB=mars_nwe

View File

@ -32,7 +32,7 @@ static time_t akttime;
static int server_goes_down=0;
static int ipx_out_fd=-1;
#if 0
static int tells_server_version=0;
static int tells_server_version=1;
#endif
static int sock_nwbind=-1;
static int sock_echo =-1;

8
net.h
View File

@ -262,6 +262,14 @@ extern int errno;
# define DO_TESTING 0
#endif
#ifdef LINUX
# ifndef QUOTA_SUPPORT
# define QUOTA_SUPPORT 0
# endif
#else
# undef QUOTA_SUPPORT
# define QUOTA_SUPPORT 0
#endif
#ifdef LINUX
# ifdef IN_NWROUTED

View File

@ -1,5 +1,5 @@
/* nwbind.c */
#define REVISION_DATE "02-Jan-97"
#define REVISION_DATE "20-Jan-97"
/* NCP Bindery SUB-SERVER */
/* authentification and some message handling */
@ -294,6 +294,30 @@ static void handle_fxx(int gelen, int func)
case 0xb: /* Get Broadcast Message (new) */
default : completition=0xfb; /* not handled */
} /* switch */
} else if (0x16 == func) {
switch (ufunc) {
/* QUOTA support from: Matt Paley */
case 0x21 : /* Change volume restrictions */
case 0x22 : /* Remove volume restrictions */
case 0x29 : { /* Read volume restrictions */
/* Returns 3 integers, uid, gid, 0=OK/1=Permission denied */
uint32 id = GET_BE32(rdata+1);
if (get_guid((int*) responsedata, (int*)(responsedata+sizeof(int)),
id, (char *) NULL) != 0) {
completition = 0xff;
XDPRINTF((2, 0, "quota id-uid mapping failure %d 0x%x", ufunc, id));
}
/* OK if supervisor or trying to read (0x29) own limits */
if (act_c->object_id == 1 ||
(act_c->object_id == id && ufunc == 0x29))
((int *) responsedata)[2] = 0; /* OK */
else
((int *) responsedata)[2] = 1; /* Fail */
data_len = sizeof(int)*3;
}
break;
default : completition=0xfb; /* not handled */
}
} else if (0x17 == func) { /* Fileserver Enviro */
switch (ufunc) {
case 0x01 : { /* Change User Password OLD */
@ -452,7 +476,7 @@ static void handle_fxx(int gelen, int func)
}
if (!result) {
internal_act = 1;
result = nw_test_adr_access(obj.id, &(act_c->client_adr));
result = nw_test_adr_time_access(obj.id, &(act_c->client_adr));
internal_act = 0;
}
if (!result)
@ -547,10 +571,9 @@ static void handle_fxx(int gelen, int func)
result=nw_test_passwd(obj.id, act_c->crypt_key, rdata);
internal_act = 0;
}
if (result > -1) {
internal_act = 1;
result = nw_test_adr_access(obj.id, &(act_c->client_adr));
result = nw_test_adr_time_access(obj.id, &(act_c->client_adr));
internal_act = 0;
}
if (result > -1)

1863
nwconn.c

File diff suppressed because it is too large Load Diff

52
nwdbm.c
View File

@ -1,4 +1,4 @@
/* nwdbm.c 19-Dec-96 data base for mars_nwe */
/* nwdbm.c 20-Jan-97 data base for mars_nwe */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -41,13 +41,16 @@
#define DBM_REMAINS_OPEN 1
int tells_server_version=0;
int tells_server_version=1; /* default 1 since 12-Jan-97 */
int password_scheme=0; /* PW_SCHEME_CHANGE_PW; */
static int entry8_flags = 0;
static datum key;
static datum data;
static DBM *my_dbm=NULL;
#define FNPROP 0
#define FNVAL 1
#define FNOBJ 2
@ -1341,7 +1344,33 @@ int nw_keychange_passwd(uint32 obj_id, uint8 *cryptkey, uint8 *oldpass,
return(memcmp(newpass, storedpass, 16) ? 0 : 1);
}
int nw_test_adr_access(uint32 obj_id, ipxAddr_t *client_adr)
static int nw_test_time_access(uint32 obj_id)
/* Routine from Matt Paley */
{
time_t t;
struct tm *tm;
uint8 more_segments;
uint8 property_flags;
char *propname="LOGIN_CONTROL";
uint8 buff[200];
int segment = 1;
int half_hours;
int result=nw_get_prop_val_by_obj_id(obj_id, segment,
propname, strlen(propname),
buff, &more_segments, &property_flags);
if (result < 0)
return(0); /* No time limits available */
time(&t);
tm = localtime(&t);
half_hours = tm->tm_wday*48 + tm->tm_hour*2 + ((tm->tm_min>=30)? 1 : 0);
if ((buff[14+(half_hours/8)] & (1<<(half_hours % 8))) != 0)
return(0);
XDPRINTF((1, 0, "No access for user %x at day %d %02d:%02d",
obj_id, tm->tm_wday, tm->tm_hour, tm->tm_min));
return(-0xda); /* unauthorized login time */
}
static int nw_test_adr_access(uint32 obj_id, ipxAddr_t *client_adr)
{
uint8 more_segments;
uint8 property_flags;
@ -1365,10 +1394,22 @@ int nw_test_adr_access(uint32 obj_id, ipxAddr_t *client_adr)
p+=10;
}
}
XDPRINTF((1, 0, "No access for Station %s", visable_ipx_adr(client_adr)));
XDPRINTF((1, 0, "No access for user %x at Station %s",
obj_id, visable_ipx_adr(client_adr)));
return(-0xdb); /* unauthorized login station */
}
int nw_test_adr_time_access(uint32 obj_id, ipxAddr_t *client_adr)
{
int result;
if (obj_id==1 && (entry8_flags & 8))
return(0); /* no limits for SU */
result=nw_test_adr_access(obj_id, client_adr);
if (!result)
result=nw_test_time_access(obj_id);
return(result);
}
#if 0
int prop_add_new_member(uint32 obj_id, int prop_id, uint32 member_id)
/* add member to set, if member not in set */
@ -1632,6 +1673,9 @@ int nw_fill_standard(char *servername, ipxAddr_t *adr)
default : password_scheme = 0;
break;
} /* switch */
} else if (8 == what) { /* entry8_flags */
entry8_flags = hextoi((char*)buff);
} else if (21 == what) { /* QUEUES */
char name[100];
char directory[200];

View File

@ -1,4 +1,4 @@
/* nwdbm.h 18-Dec-96 */
/* nwdbm.h 20-Jan-97 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -192,7 +192,7 @@ extern int nw_keychange_passwd(uint32 obj_id,
int cryptedlen, uint8 *newpass,
uint32 act_id);
extern int nw_test_adr_access(uint32 obj_id, ipxAddr_t *client_adr);
extern int nw_test_adr_time_access(uint32 obj_id, ipxAddr_t *client_adr);
extern int nw_get_q_dirname(uint32 q_id, uint8 *buff);
extern int nw_get_q_prcommand(uint32 q_id, uint8 *buff);

View File

@ -1,4 +1,4 @@
/* nwfile.c 31-Dec-96 */
/* nwfile.c 14-Jan-97 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -683,9 +683,15 @@ int nw_server_copy(int qfhandle, uint32 qoffset,
return(-0x88); /* wrong filehandle */
}
int nw_lock_datei(int fhandle, int offset, int size, int do_lock)
{
MDEBUG(D_FH_LOCK, {
char fname[200];
int r=fd_2_fname(fhandle, fname, sizeof(fname));
dprintf("nw_%s_datei: fd=%d, fn=`%s`,r=%d,offs=%d,len=%d",
(do_lock) ? "lock" : "unlock",
fhandle, fname,r,offset, size);
})
if (fhandle > HOFFS && (--fhandle < anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
if (fh->fd > -1) {

View File

@ -383,12 +383,24 @@ int nw_close_file_queue(uint8 *queue_id,
INT_QUEUE_JOB *jo=queue_jobs[jo_id-1];
int fhandle = (int)jo->fhandle;
char unixname[300];
QUEUE_PRINT_AREA qpa;
if (jo->old_job) {
memcpy(&qpa, jo->q.o.client_area, sizeof(QUEUE_PRINT_AREA));
} else {
memcpy(&qpa, jo->q.n.client_area, sizeof(QUEUE_PRINT_AREA));
}
strmaxcpy((uint8*)unixname, (uint8*)file_get_unix_name(fhandle), sizeof(unixname)-1);
XDPRINTF((5,0,"nw_close_file_queue fhandle=%d", fhandle));
if (*unixname) {
char printcommand[256];
char buff[1024];
char printcommand[300];
FILE *f=NULL;
strmaxcpy((uint8*)printcommand, prc, prc_len);
if (prc_len && *(prc+prc_len-1)=='!'){
strmaxcpy((uint8*)buff, prc, prc_len-1);
sprintf(printcommand, "%s %s %s", buff,
qpa.banner_user_name, qpa.banner_file_name);
} else
strmaxcpy((uint8*)printcommand, prc, prc_len);
nw_close_datei(fhandle, 1);
jo->fhandle = 0L;
if (NULL == (f = fopen(unixname, "r"))) {
@ -401,7 +413,6 @@ int nw_close_file_queue(uint8 *queue_id,
int is_ok = 0;
FILE_PIPE *fp = ext_popen(printcommand, geteuid(), getegid());
if (fp) {
char buff[1024];
int k;
is_ok++;
while ((k = fread(buff, 1, sizeof(buff), f)) > 0) {

View File

@ -79,8 +79,8 @@ typedef struct {
uint8 form_name[16]; /* "UNKNOWN" */
uint8 reserved[6]; /* all zero */
uint8 banner_user_name[13]; /* "SUPERVISOR" */
uint8 bannner_file_name[13]; /* "LST:" */
uint8 bannner_header_file_name[14]; /* all zero */
uint8 banner_file_name[13]; /* "LST:" */
uint8 banner_header_file_name[14]; /* all zero */
uint8 file_path_name[80]; /* all zero */
} QUEUE_PRINT_AREA;

View File

@ -1,4 +1,4 @@
/* nwvolume.c 07-Nov-96 */
/* nwvolume.c 01-Feb-97 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -19,6 +19,7 @@
#include "net.h"
#include <dirent.h>
#include <errno.h>
#include <sys/vfs.h>
#ifndef LINUX
@ -39,6 +40,7 @@ static void volume_to_namespace_map(int volume, NW_VOL *vol)
DEV_NAMESPACE_MAP dnm;
if (stat(vol->unixname, &statb)) {
XDPRINTF((1, 0, "cannot stat vol=%d, `%s`", volume, vol->unixname));
return;
}
dnm.dev = statb.st_dev;
dnm.namespace = 0; /* NAMESPACE DOS */
@ -162,7 +164,7 @@ void nw_setup_home_vol(int len, uint8 *fn)
nw_volumes[k].maps_count = 0;
nw_volumes[k].unixnamlen = len;
new_str(nw_volumes[k].unixname, unixname);
if (len)
if (len>0)
volume_to_namespace_map(k, &(nw_volumes[k]));
}
}
@ -277,7 +279,7 @@ int nw_get_volume_name(int volnr, uint8 *volname)
}
/* next is stolen from GNU-fileutils */
/* stolen from GNU-fileutils */
static long adjust_blocks (long blocks, int fromsize, int tosize)
{
if (fromsize == tosize) /* E.g., from 512 to 512. */
@ -366,3 +368,170 @@ int get_volume_inode(int volnr, struct stat *stb)
return(result);
}
#if QUOTA_SUPPORT
/* QUOTA support from: Matt Paley */
#include <sys/stat.h>
#include <unistd.h>
#include <mntent.h>
/* Return the device special file that the specified path uses */
const char *find_device_file(const char *path)
{
struct stat s;
dev_t dev;
struct mntent *mntent;
FILE *fp;
const char *mount_device;
if (path == (char *) NULL || *path == '\0' || stat(path, &s) != 0)
return((char *) NULL);
dev = s.st_dev;
if ((fp=setmntent(MOUNTED, "r")) == (FILE *) NULL)
return((char *) NULL);
mount_device = (char *) NULL;
while (!ferror(fp)) {
/* mntent will be a static struct mntent */
mntent = getmntent(fp);
if (mntent == (struct mntent *) NULL)
break;
if (stat(mntent->mnt_fsname, &s) == 0) {
if (S_ISCHR(s.st_mode) || S_ISBLK(s.st_mode)) {
if (s.st_rdev == dev) {
/* Found it */
mount_device = mntent->mnt_fsname;
break;
}
}
}
}
endmntent(fp);
return(mount_device);
}
#include <time.h>
#include <sys/types.h>
#ifdef LINUX
# include <linux/quota.h>
# if defined(__alpha__)
# include <errno.h>
# include <syscall.h>
# include <asm/unistd.h>
int quotactl(int cmd, const char * special, int id, caddr_t addr)
{
return syscall(__NR_quotactl, cmd, special, id, addr);
}
# else /* not __alpha__ */
# define __LIBRARY__
# include <linux/unistd.h>
_syscall4(int, quotactl, int, cmd, const char *, special,
int, id, caddr_t, addr);
# endif /* __alpha__ */
#endif /* LINUX */
static int su_quotactl(int cmd, const char * special, int id, caddr_t addr)
{
int result;
int euid=geteuid();
seteuid(0);
result=quotactl(cmd, special, id, addr);
if (seteuid(euid)) {
errorp(1, "seteuid", "cannot change to uid=%d\n", euid);
exit(1);
}
return(result);
}
/* NOTE: The error numbers in here are probably wrong */
int nw_set_vol_restrictions(uint8 volnr, int uid, uint32 quota)
{
const char *device;
struct dqblk dqblk;
int res;
XDPRINTF((2,0, "nw_set_vol_restrictions vol=%d uid=%d quota=%d blocks",
volnr, uid, quota));
/* Convert from blocks to K */
quota *= 4;
if (volnr >= used_nw_volumes || nw_volumes == (NW_VOL *) NULL)
return(-0x98);
device=find_device_file(nw_volumes[volnr].unixname);
if (device == (char *) NULL)
return(-0x98);
/* If this call fails then it it probable that quotas are not enabled
* on the specified device. Someone needs to set the error number
* to whatever will make most sense to netware.
*/
res=su_quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device, uid, (caddr_t) &dqblk);
if (res != 0)
return(0);
dqblk.dqb_bhardlimit = quota;
dqblk.dqb_bsoftlimit = quota;
if (quota == 0)
dqblk.dqb_ihardlimit = dqblk.dqb_isoftlimit = 0;
XDPRINTF((2,0, "Set quota device=%s uid=%d %d(%d)K %d(%d) files",
device, uid,
dqblk.dqb_bhardlimit,
dqblk.dqb_curblocks,
dqblk.dqb_ihardlimit,
dqblk.dqb_curinodes));
(void)su_quotactl(QCMD(Q_SETQLIM, USRQUOTA), device, uid, (caddr_t) &dqblk);
return(0);
}
int nw_get_vol_restrictions(uint8 volnr, int uid, uint32 *quota, uint32 *inuse)
{
const char *device;
struct dqblk dqblk;
int res;
*quota = 0x40000000;
*inuse = 0;
if (volnr >= used_nw_volumes || nw_volumes == (NW_VOL *) NULL)
return(-0x98);
device=find_device_file(nw_volumes[volnr].unixname);
if (device == (char *) NULL)
return(-0x98);
XDPRINTF((2,0, "Get quota for uid %d on device %s",
uid, device));
res=su_quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device, uid, (caddr_t) &dqblk);
if (res != 0)
return(0); /* Quotas are probably not enabled */
if (dqblk.dqb_bhardlimit == 0) {
*quota = 0x40000000;
*inuse = 0;
} else {
*quota = dqblk.dqb_bhardlimit / 4; /* Convert from K to blocks */
*inuse = dqblk.dqb_curblocks / 4;
}
return(0);
}
#else
int nw_set_vol_restrictions(uint8 volnr, int uid, uint32 quota)
{
return(-0xfb);
}
int nw_get_vol_restrictions(uint8 volnr, int uid, uint32 *quota, uint32 *inuse)
{
*quota = 0x40000000;
*inuse = 0;
return(0);
}
#endif

View File

@ -1,4 +1,4 @@
/* nwvolume.h 27-Jul-96 */
/* nwvolume.h 17-Jan-97 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -76,7 +76,9 @@ extern int nw_get_volume_number(uint8 *volname, int namelen);
extern int nw_get_volume_name(int volnr, uint8 *volname);
extern int nw_get_fs_usage(uint8 *volname, struct fs_usage *fsu);
extern int get_volume_options(int volnr, int mode);
extern int get_volume_inode(int volnr, struct stat *stb);
extern int get_volume_inode(int volnr, struct stat *stb);
extern int nw_set_vol_restrictions(uint8 volnr, int uid, uint32 quota);
extern int nw_get_vol_restrictions(uint8 volnr, int uid, uint32 *quota, uint32 *inuse);
extern uint32 nw_vol_inode_to_handle(int volume, ino_t inode,
DEV_NAMESPACE_MAP *dnm);